<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/*! 
<span class='line'>  2</span>  * Timemap.js Copyright 2008 Nick Rabinowitz.
<span class='line'>  3</span>  * Licensed under the MIT License (see LICENSE.txt)
<span class='line'>  4</span>  */</span><span class="WHIT">
<span class='line'>  5</span> 
<span class='line'>  6</span> </span><span class="COMM">/**
<span class='line'>  7</span>  * @overview
<span class='line'>  8</span>  *
<span class='line'>  9</span>  * &lt;p>Timemap.js is intended to sync a SIMILE Timeline with a Google Map. 
<span class='line'> 10</span>  * Depends on: Google Maps API v2, SIMILE Timeline v1.2 - 2.3.1. 
<span class='line'> 11</span>  * Thanks to Jorn Clausen (http://www.oe-files.de) for initial concept and code. 
<span class='line'> 12</span>  * Timemap.js is licensed under the MIT License (see &lt;a href="../LICENSE.txt">LICENSE.txt&lt;/a>).&lt;/p>
<span class='line'> 13</span>  * &lt;ul>
<span class='line'> 14</span>  *     &lt;li>&lt;a href="http://code.google.com/p/timemap/">Project Homepage&lt;/a>&lt;/li>
<span class='line'> 15</span>  *     &lt;li>&lt;a href="http://groups.google.com/group/timemap-development">Discussion Group&lt;/a>&lt;/li>
<span class='line'> 16</span>  *     &lt;li>&lt;a href="../examples/index.html">Working Examples&lt;/a>&lt;/li>
<span class='line'> 17</span>  * &lt;/ul>
<span class='line'> 18</span>  *
<span class='line'> 19</span>  * @name timemap.js
<span class='line'> 20</span>  * @author Nick Rabinowitz (www.nickrabinowitz.com)
<span class='line'> 21</span>  * @version 1.6
<span class='line'> 22</span>  */</span><span class="WHIT">
<span class='line'> 23</span> 
<span class='line'> 24</span> </span><span class="COMM">// globals - for JSLint</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="COMM">/*global GBrowserIsCompatible, GLargeMapControl, GMap2, GIcon       */</span><span class="WHIT"> 
<span class='line'> 26</span> </span><span class="COMM">/*global GMapTypeControl, GDownloadUrl, GGroundOverlay              */</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="COMM">/*global GMarker, GPolygon, GPolyline, GSize, G_DEFAULT_ICON        */</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="COMM">/*global G_HYBRID_MAP, G_MOON_VISIBLE_MAP, G_SKY_VISIBLE_MAP        */</span><span class="WHIT">
<span class='line'> 29</span> 
<span class='line'> 30</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 31</span> 
<span class='line'> 32</span> </span><span class="COMM">// borrowing some space-saving devices from jquery</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="KEYW">var</span><span class="WHIT"> 
<span class='line'> 34</span> 	</span><span class="COMM">// Will speed up references to window, and allows munging its name.</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT">	</span><span class="NAME">window</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">	</span><span class="COMM">// Will speed up references to undefined, and allows munging its name.</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT">	</span><span class="NAME">undefined</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT">    </span><span class="COMM">// aliases for Timeline objects</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="WHIT">    </span><span class="NAME">Timeline</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.Timeline</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">DateTime</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Timeline.DateTime</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'> 40</span>     </span><span class="COMM">// aliases for Google variables (anything that gets used more than once)</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">    </span><span class="NAME">G_DEFAULT_MAP_TYPES</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.G_DEFAULT_MAP_TYPES</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'> 42</span>     </span><span class="NAME">G_NORMAL_MAP</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.G_NORMAL_MAP</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'> 43</span>     </span><span class="NAME">G_PHYSICAL_MAP</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.G_PHYSICAL_MAP</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'> 44</span>     </span><span class="NAME">G_SATELLITE_MAP</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.G_SATELLITE_MAP</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'> 45</span>     </span><span class="NAME">GLatLng</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.GLatLng</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'> 46</span>     </span><span class="NAME">GLatLngBounds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.GLatLngBounds</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'> 47</span>     </span><span class="NAME">GEvent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.GEvent</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">    </span><span class="COMM">// Google icon path</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">    </span><span class="NAME">GIP</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"http://www.google.com/intl/en_us/mapfiles/ms/icons/"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">    </span><span class="COMM">// aliases for class names, allowing munging</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">    </span><span class="NAME">TimeMap</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TimeMapFilterChain</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TimeMapDataset</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TimeMapItem</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 52</span> 
<span class='line'> 53</span> </span><span class="COMM">/*----------------------------------------------------------------------------
<span class='line'> 54</span>  * TimeMap Class
<span class='line'> 55</span>  *---------------------------------------------------------------------------*/</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT"> 
<span class='line'> 57</span> </span><span class="COMM">/**
<span class='line'> 58</span>  * @class
<span class='line'> 59</span>  * The TimeMap object holds references to timeline, map, and datasets.
<span class='line'> 60</span>  *
<span class='line'> 61</span>  * @constructor
<span class='line'> 62</span>  * This will create the visible map, but not the timeline, which must be initialized separately.
<span class='line'> 63</span>  *
<span class='line'> 64</span>  * @param {DOM Element} tElement     The timeline element.
<span class='line'> 65</span>  * @param {DOM Element} mElement     The map element.
<span class='line'> 66</span>  * @param {Object} [options]       A container for optional arguments
<span class='line'> 67</span>  * @param {TimeMapTheme|String} [options.theme=red] Color theme for the timemap
<span class='line'> 68</span>  * @param {Boolean} [options.syncBands=true]    Whether to synchronize all bands in timeline
<span class='line'> 69</span>  * @param {GLatLng} [options.mapCenter=0,0]     Point for map center
<span class='line'> 70</span>  * @param {Number} [options.mapZoom=0]          Initial map zoom level
<span class='line'> 71</span>  * @param {GMapType|String} [options.mapType=physical]  The maptype for the map
<span class='line'> 72</span>  * @param {Array} [options.mapTypes=normal,satellite,physical]  The set of maptypes available for the map
<span class='line'> 73</span>  * @param {Function|String} [options.mapFilter={@link TimeMap.filters.hidePastFuture}] 
<span class='line'> 74</span>  *                                              How to hide/show map items depending on timeline state;
<span class='line'> 75</span>  *                                              options: keys in {@link TimeMap.filters} or function
<span class='line'> 76</span>  * @param {Boolean} [options.showMapTypeCtrl=true]  Whether to display the map type control
<span class='line'> 77</span>  * @param {Boolean} [options.showMapCtrl=true]      Whether to show map navigation control
<span class='line'> 78</span>  * @param {Boolean} [options.centerMapOnItems=true] Whether to center and zoom the map based on loaded item 
<span class='line'> 79</span>  * @param {Boolean} [options.noEventLoad=false]     Whether to skip loading events on the timeline
<span class='line'> 80</span>  * @param {Boolean} [options.noPlacemarkLoad=false] Whether to skip loading placemarks on the map
<span class='line'> 81</span>  * @param {String} [options.eventIconPath]      Path for directory holding event icons; if set at the TimeMap
<span class='line'> 82</span>  *                                              level, will override dataset and item defaults
<span class='line'> 83</span>  * @param {String} [options.infoTemplate]       HTML for the info window content, with variable expressions
<span class='line'> 84</span>  *                                              (as "{{varname}}" by default) to be replaced by option data
<span class='line'> 85</span>  * @param {String} [options.templatePattern]    Regex pattern defining variable syntax in the infoTemplate
<span class='line'> 86</span>  * @param {Function} [options.openInfoWindow={@link TimeMapItem.openInfoWindowBasic}]   
<span class='line'> 87</span>  *                                              Function redefining how info window opens
<span class='line'> 88</span>  * @param {Function} [options.closeInfoWindow={@link TimeMapItem.closeInfoWindowBasic}]  
<span class='line'> 89</span>  *                                              Function redefining how info window closes
<span class='line'> 90</span>  * @param {mixed} [options[...]]                Any of the options for {@link TimeMapTheme} may be set here,
<span class='line'> 91</span>  *                                              to cascade to the entire TimeMap, though they can be overridden
<span class='line'> 92</span>  *                                              at lower levels
<span class='line'> 93</span>  * &lt;/pre>
<span class='line'> 94</span>  */</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="NAME">TimeMap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">tElement</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">mElement</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">        </span><span class="COMM">// set defaults for options</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">        </span><span class="NAME">defaults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">            </span><span class="NAME">mapCenter</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GLatLng</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">            </span><span class="NAME">mapZoom</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">            </span><span class="NAME">mapType</span><span class="PUNC">:</span><span class="WHIT">            </span><span class="NAME">G_PHYSICAL_MAP</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">            </span><span class="NAME">mapTypes</span><span class="PUNC">:</span><span class="WHIT">           </span><span class="PUNC">[</span><span class="NAME">G_NORMAL_MAP</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">G_SATELLITE_MAP</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">G_PHYSICAL_MAP</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">            </span><span class="NAME">showMapTypeCtrl</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">            </span><span class="NAME">showMapCtrl</span><span class="PUNC">:</span><span class="WHIT">        </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">            </span><span class="NAME">syncBands</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">            </span><span class="NAME">mapFilter</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="STRN">'hidePastFuture'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">            </span><span class="NAME">centerOnItems</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">            </span><span class="NAME">theme</span><span class="PUNC">:</span><span class="WHIT">              </span><span class="STRN">'red'</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">    
<span class='line'>111</span>     </span><span class="COMM">// save DOM elements</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>113</span>      * Map element
<span class='line'>114</span>      * @name TimeMap#mElement
<span class='line'>115</span>      * @type DOM Element
<span class='line'>116</span>      */</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">    </span><span class="NAME">tm.mElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mElement</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>119</span>      * Timeline element
<span class='line'>120</span>      * @name TimeMap#tElement
<span class='line'>121</span>      * @type DOM Element
<span class='line'>122</span>      */</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">    </span><span class="NAME">tm.tElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tElement</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">    
<span class='line'>125</span>     </span><span class="COMM">/** 
<span class='line'>126</span>      * Map of datasets 
<span class='line'>127</span>      * @name TimeMap#datasets
<span class='line'>128</span>      * @type Object 
<span class='line'>129</span>      */</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">    </span><span class="NAME">tm.datasets</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>132</span>      * Filter chains for this timemap 
<span class='line'>133</span>      * @name TimeMap#chains
<span class='line'>134</span>      * @type Object
<span class='line'>135</span>      */</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">    </span><span class="NAME">tm.chains</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">    
<span class='line'>138</span>     </span><span class="COMM">/** 
<span class='line'>139</span>      * Container for optional settings passed in the "options" parameter
<span class='line'>140</span>      * @name TimeMap#opts
<span class='line'>141</span>      * @type Object
<span class='line'>142</span>      */</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">    </span><span class="NAME">tm.opts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.merge</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">defaults</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">    
<span class='line'>145</span>     </span><span class="COMM">// only these options will cascade to datasets and items</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">    </span><span class="NAME">options.mergeOnly</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'mergeOnly'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'theme'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'eventIconPath'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'openInfoWindow'</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>147</span>                          </span><span class="STRN">'closeInfoWindow'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'noPlacemarkLoad'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'noEventLoad'</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>148</span>                          </span><span class="STRN">'infoTemplate'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'templatePattern'</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">    
<span class='line'>150</span>     </span><span class="COMM">// allow map types to be specified by key</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">    </span><span class="NAME">options.mapType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.lookup</span><span class="PUNC">(</span><span class="NAME">options.mapType</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TimeMap.mapTypes</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">    </span><span class="COMM">// allow map filters to be specified by key</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">    </span><span class="NAME">options.mapFilter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.lookup</span><span class="PUNC">(</span><span class="NAME">options.mapFilter</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TimeMap.filters</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">    </span><span class="COMM">// allow theme options to be specified in options</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">    </span><span class="NAME">options.theme</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme.create</span><span class="PUNC">(</span><span class="NAME">options.theme</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">    
<span class='line'>157</span>     </span><span class="COMM">// initialize map</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">    </span><span class="NAME">tm.initMap</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>159</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>160</span> 
<span class='line'>161</span> </span><span class="COMM">/**
<span class='line'>162</span>  * Initialize the map.
<span class='line'>163</span>  */</span><span class="WHIT">
<span class='line'>164</span> </span><span class="NAME">TimeMap.prototype.initMap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.opts</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">map</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">GBrowserIsCompatible</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">    
<span class='line'>168</span>         </span><span class="COMM">/** 
<span class='line'>169</span>          * The associated GMap object 
<span class='line'>170</span>          * @type GMap2
<span class='line'>171</span>          */</span><span class="WHIT">
<span class='line'>172</span> </span><span class="WHIT">        </span><span class="NAME">this.map</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">map</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GMap2</span><span class="PUNC">(</span><span class="NAME">this.mElement</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>173</span> </span><span class="WHIT">        
<span class='line'>174</span>         </span><span class="COMM">// drop all existing types</span><span class="WHIT">
<span class='line'>175</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">G_DEFAULT_MAP_TYPES.length</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">></span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">            </span><span class="NAME">map.removeMapType</span><span class="PUNC">(</span><span class="NAME">G_DEFAULT_MAP_TYPES</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>177</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>178</span> </span><span class="WHIT">        </span><span class="COMM">// you can't remove the last maptype, so add a new one first</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">        </span><span class="NAME">map.addMapType</span><span class="PUNC">(</span><span class="NAME">options.mapTypes</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">        </span><span class="NAME">map.removeMapType</span><span class="PUNC">(</span><span class="NAME">G_DEFAULT_MAP_TYPES</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">        </span><span class="COMM">// add the rest of the new types</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">options.mapTypes.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">            </span><span class="NAME">map.addMapType</span><span class="PUNC">(</span><span class="NAME">options.mapTypes</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">        
<span class='line'>186</span>         </span><span class="COMM">// initialize map center, zoom, and map type</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">        </span><span class="NAME">map.setCenter</span><span class="PUNC">(</span><span class="NAME">options.mapCenter</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options.mapZoom</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options.mapType</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">        
<span class='line'>189</span>         </span><span class="COMM">// set basic parameters</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT">        </span><span class="NAME">map.enableDoubleClickZoom</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">        </span><span class="NAME">map.enableScrollWheelZoom</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT">        </span><span class="NAME">map.enableContinuousZoom</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">        
<span class='line'>194</span>         </span><span class="COMM">// set controls</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">options.showMapCtrl</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">            </span><span class="NAME">map.addControl</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GLargeMapControl</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">options.showMapTypeCtrl</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">            </span><span class="NAME">map.addControl</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GMapTypeControl</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">        
<span class='line'>202</span>         </span><span class="COMM">/** 
<span class='line'>203</span>          * Bounds of the map 
<span class='line'>204</span>          * @type GLatLngBounds
<span class='line'>205</span>          */</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT">        </span><span class="NAME">this.mapBounds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options.mapZoom</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT">            </span><span class="COMM">// if the zoom has been set, use the map bounds</span><span class="WHIT">
<span class='line'>208</span> </span><span class="WHIT">            </span><span class="NAME">map.getBounds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT">            </span><span class="COMM">// otherwise, start from scratch</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">            </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GLatLngBounds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>212</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>213</span> 
<span class='line'>214</span> </span><span class="COMM">/**
<span class='line'>215</span>  * Current library version.
<span class='line'>216</span>  * @constant
<span class='line'>217</span>  * @type String
<span class='line'>218</span>  */</span><span class="WHIT">
<span class='line'>219</span> </span><span class="NAME">TimeMap.version</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"1.6"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> 
<span class='line'>221</span> </span><span class="COMM">/**
<span class='line'>222</span>  * @name TimeMap.util
<span class='line'>223</span>  * @namespace
<span class='line'>224</span>  * Namespace for TimeMap utility functions.
<span class='line'>225</span>  */</span><span class="WHIT">
<span class='line'>226</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">util</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.util</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>227</span> 
<span class='line'>228</span> </span><span class="COMM">/**
<span class='line'>229</span>  * Intializes a TimeMap.
<span class='line'>230</span>  *
<span class='line'>231</span>  * &lt;p>The idea here is to throw all of the standard intialization settings into
<span class='line'>232</span>  * a large object and then pass it to the TimeMap.init() function. The full
<span class='line'>233</span>  * data format is outlined below, but if you leave elements out the script 
<span class='line'>234</span>  * will use default settings instead.&lt;/p>
<span class='line'>235</span>  *
<span class='line'>236</span>  * &lt;p>See the examples and the 
<span class='line'>237</span>  * &lt;a href="http://code.google.com/p/timemap/wiki/UsingTimeMapInit">UsingTimeMapInit wiki page&lt;/a>
<span class='line'>238</span>  * for usage.&lt;/p>
<span class='line'>239</span>  *
<span class='line'>240</span>  * @param {Object} config                           Full set of configuration options.
<span class='line'>241</span>  * @param {String} config.mapId                     DOM id of the element to contain the map
<span class='line'>242</span>  * @param {String} config.timelineId                DOM id of the element to contain the timeline
<span class='line'>243</span>  * @param {Object} [config.options]                 Options for the TimeMap object (see the {@link TimeMap} constructor)
<span class='line'>244</span>  * @param {Object[]} config.datasets                Array of datasets to load
<span class='line'>245</span>  * @param {Object} config.datasets[x]               Configuration options for a particular dataset
<span class='line'>246</span>  * @param {String|Class} config.datasets[x].type    Loader type for this dataset (generally a sub-class 
<span class='line'>247</span>  *                                                  of {@link TimeMap.loaders.base})
<span class='line'>248</span>  * @param {Object} config.datasets[x].options       Options for the loader. See the {@link TimeMap.loaders.base}
<span class='line'>249</span>  *                                                  constructor and the constructors for the various loaders for 
<span class='line'>250</span>  *                                                  more details.
<span class='line'>251</span>  * @param {String} [config.datasets[x].id]          Optional id for the dataset in the {@link TimeMap#datasets}
<span class='line'>252</span>  *                                                  object, for future reference; otherwise "ds"+x is used
<span class='line'>253</span>  * @param {String} [config.datasets[x][...]]         Other options for the {@link TimeMapDataset} object
<span class='line'>254</span>  * @param {String|Array} [config.bandIntervals]     Intervals for the two default timeline bands. Can either be an 
<span class='line'>255</span>  *                                                  array of interval constants or a key in {@link TimeMap.intervals}
<span class='line'>256</span>  * @param {Object[]} [config.bandInfo]              Array of configuration objects for Timeline bands, to be passed to
<span class='line'>257</span>  *                                                  Timeline.createBandInfo (see the &lt;a href="http://code.google.com/p/simile-widgets/wiki/Timeline_GettingStarted">Timeline Getting Started tutorial&lt;/a>).
<span class='line'>258</span>  *                                                  This will override config.bandIntervals, if provided.
<span class='line'>259</span>  * @param {Timeline.Band[]} [config.bands]          Array of instantiated Timeline Band objects. This will override
<span class='line'>260</span>  *                                                  config.bandIntervals and config.bandInfo, if provided.
<span class='line'>261</span>  * @param {Function} [config.dataLoadedFunction]    Function to be run as soon as all datasets are loaded, but
<span class='line'>262</span>  *                                                  before they've been displayed on the map and timeline
<span class='line'>263</span>  *                                                  (this will override dataDisplayedFunction and scrollTo)
<span class='line'>264</span>  * @param {Function} [config.dataDisplayedFunction] Function to be run as soon as all datasets are loaded and 
<span class='line'>265</span>  *                                                  displayed on the map and timeline
<span class='line'>266</span>  * @param {String|Date} [config.scrollTo]           Date to scroll to once data is loaded - see 
<span class='line'>267</span>  *                                                  {@link TimeMap.parseDate} for options; default is "earliest"
<span class='line'>268</span>  * @return {TimeMap}                                The initialized TimeMap object
<span class='line'>269</span>  */</span><span class="WHIT">
<span class='line'>270</span> </span><span class="NAME">TimeMap.init</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">config</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">err</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"TimeMap.init: No id for "</span><span class="PUNC">,</span><span class="WHIT">    
<span class='line'>272</span>         </span><span class="COMM">// set defaults</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">        </span><span class="NAME">defaults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">            </span><span class="NAME">options</span><span class="PUNC">:</span><span class="WHIT">        </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">            </span><span class="NAME">datasets</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">            </span><span class="NAME">bands</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">            </span><span class="NAME">bandInfo</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">            </span><span class="NAME">bandIntervals</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="STRN">"wk"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">            </span><span class="NAME">scrollTo</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="STRN">"earliest"</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">        </span><span class="NAME">state</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.state</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">        </span><span class="NAME">intervals</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tm</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">        </span><span class="NAME">datasets</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ds</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dsOptions</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">topOptions</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dsId</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">        </span><span class="NAME">bands</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">eventSource</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">bandInfo</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">    
<span class='line'>286</span>     </span><span class="COMM">// check required elements</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="STRN">'mapId'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">config</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">config.mapId</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">        </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">err</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"map"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="STRN">'timelineId'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">config</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">config.timelineId</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">        </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">err</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"timeline"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">    
<span class='line'>294</span>     </span><span class="COMM">// get state from url hash if state functions are available</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">state</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT">        </span><span class="NAME">state.setConfigFromUrl</span><span class="PUNC">(</span><span class="NAME">config</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>298</span> </span><span class="WHIT">    </span><span class="COMM">// merge options and defaults</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT">    </span><span class="NAME">config</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.merge</span><span class="PUNC">(</span><span class="NAME">config</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">defaults</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>300</span> 
<span class='line'>301</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">config.bandInfo</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">config.bands</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT">        </span><span class="COMM">// allow intervals to be specified by key</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">        </span><span class="NAME">intervals</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.lookup</span><span class="PUNC">(</span><span class="NAME">config.bandIntervals</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TimeMap.intervals</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">        </span><span class="COMM">// make default band info</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">        </span><span class="NAME">config.bandInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT">    		
<span class='line'>306</span>             </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">                </span><span class="NAME">width</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="STRN">"80%"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>308</span>                 </span><span class="NAME">intervalUnit</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">intervals</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>309</span>                 </span><span class="NAME">intervalPixels</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">70</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">            </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">                </span><span class="NAME">width</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="STRN">"20%"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>313</span>                 </span><span class="NAME">intervalUnit</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">intervals</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>314</span>                 </span><span class="NAME">intervalPixels</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">100</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>315</span> </span><span class="WHIT">                </span><span class="NAME">showEventText</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT">                </span><span class="NAME">overview</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>317</span> </span><span class="WHIT">                </span><span class="NAME">trackHeight</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="NUMB">0.4</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>318</span> </span><span class="WHIT">                </span><span class="NAME">trackGap</span><span class="PUNC">:</span><span class="WHIT">       </span><span class="NUMB">0.2</span><span class="WHIT">
<span class='line'>319</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>320</span> </span><span class="WHIT">        </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>321</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>322</span> </span><span class="WHIT">    
<span class='line'>323</span>     </span><span class="COMM">// create the TimeMap object</span><span class="WHIT">
<span class='line'>324</span> </span><span class="WHIT">    </span><span class="NAME">tm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMap</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>325</span> </span><span class="WHIT">  		</span><span class="NAME">document.getElementById</span><span class="PUNC">(</span><span class="NAME">config.timelineId</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>326</span> 		</span><span class="NAME">document.getElementById</span><span class="PUNC">(</span><span class="NAME">config.mapId</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>327</span> </span><span class="WHIT">		</span><span class="NAME">config.options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>328</span> </span><span class="WHIT">    
<span class='line'>329</span>     </span><span class="COMM">// create the dataset objects</span><span class="WHIT">
<span class='line'>330</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">config.datasets.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>331</span> </span><span class="WHIT">        </span><span class="NAME">ds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">config.datasets</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>332</span> </span><span class="WHIT">        </span><span class="COMM">// put top-level data into options</span><span class="WHIT">
<span class='line'>333</span> </span><span class="WHIT">        </span><span class="NAME">topOptions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">            </span><span class="NAME">title</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">ds.title</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">            </span><span class="NAME">theme</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">ds.theme</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>336</span> </span><span class="WHIT">            </span><span class="NAME">dateParser</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">ds.dateParser</span><span class="WHIT">
<span class='line'>337</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>338</span> </span><span class="WHIT">        </span><span class="NAME">dsOptions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.merge</span><span class="PUNC">(</span><span class="NAME">ds.options</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">topOptions</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT">        </span><span class="NAME">dsId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ds.id</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">"ds"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>340</span> </span><span class="WHIT">        </span><span class="NAME">datasets</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tm.createDataset</span><span class="PUNC">(</span><span class="NAME">dsId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dsOptions</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>341</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">            </span><span class="COMM">// set all to the same eventSource</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">            </span><span class="NAME">datasets</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">eventSource</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">datasets</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">eventSource</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>344</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>345</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>346</span> </span><span class="WHIT">    </span><span class="COMM">// add a pointer to the eventSource in the TimeMap</span><span class="WHIT">
<span class='line'>347</span> </span><span class="WHIT">    </span><span class="NAME">tm.eventSource</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">datasets</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">eventSource</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>348</span> </span><span class="WHIT">    
<span class='line'>349</span>     </span><span class="COMM">// set up timeline bands</span><span class="WHIT">
<span class='line'>350</span> </span><span class="WHIT">    </span><span class="COMM">// ensure there's at least an empty eventSource</span><span class="WHIT">
<span class='line'>351</span> </span><span class="WHIT">    </span><span class="NAME">eventSource</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">datasets</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">datasets</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">eventSource</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Timeline.DefaultEventSource</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>352</span> </span><span class="WHIT">    </span><span class="COMM">// check for pre-initialized bands (manually created with Timeline.createBandInfo())</span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">config.bands</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>354</span> </span><span class="WHIT">        </span><span class="NAME">bands</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">config.bands</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>355</span> </span><span class="WHIT">        </span><span class="COMM">// substitute dataset event source</span><span class="WHIT">
<span class='line'>356</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">bands.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>357</span> </span><span class="WHIT">            </span><span class="COMM">// assume that these have been set up like "normal" Timeline bands:</span><span class="WHIT">
<span class='line'>358</span> </span><span class="WHIT">            </span><span class="COMM">// with an empty event source if events are desired, and null otherwise</span><span class="WHIT">
<span class='line'>359</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">bands</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">eventSource</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>360</span> </span><span class="WHIT">                </span><span class="NAME">bands</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">eventSource</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eventSource</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>361</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>362</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>363</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>364</span> </span><span class="WHIT">    </span><span class="COMM">// otherwise, make bands from band info</span><span class="WHIT">
<span class='line'>365</span> </span><span class="WHIT">    </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>366</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">config.bandInfo.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>367</span> </span><span class="WHIT">            </span><span class="NAME">bandInfo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">config.bandInfo</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>368</span> </span><span class="WHIT">            </span><span class="COMM">// if eventSource is explicitly set to null or false, ignore</span><span class="WHIT">
<span class='line'>369</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="STRN">'eventSource'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">bandInfo</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">bandInfo.eventSource</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>370</span> </span><span class="WHIT">                </span><span class="NAME">bandInfo.eventSource</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eventSource</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>371</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>372</span> </span><span class="WHIT">            </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>373</span> </span><span class="WHIT">                </span><span class="NAME">bandInfo.eventSource</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>374</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>375</span> </span><span class="WHIT">            </span><span class="NAME">bands</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Timeline.createBandInfo</span><span class="PUNC">(</span><span class="NAME">bandInfo</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>376</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">util.TimelineVersion</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"1.2"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>377</span> </span><span class="WHIT">                </span><span class="COMM">// set all to the same layout</span><span class="WHIT">
<span class='line'>378</span> </span><span class="WHIT">                </span><span class="NAME">bands</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">eventPainter.setLayout</span><span class="PUNC">(</span><span class="NAME">bands</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">eventPainter.getLayout</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> 
<span class='line'>379</span>             </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">    </span><span class="COMM">// initialize timeline</span><span class="WHIT">
<span class='line'>383</span> </span><span class="WHIT">    </span><span class="NAME">tm.initTimeline</span><span class="PUNC">(</span><span class="NAME">bands</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>384</span> </span><span class="WHIT">    
<span class='line'>385</span>     </span><span class="COMM">// initialize load manager</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">loadManager</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.loadManager</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>387</span> </span><span class="WHIT">    </span><span class="NAME">loadManager.init</span><span class="PUNC">(</span><span class="NAME">tm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">config.datasets.length</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">config</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT">    
<span class='line'>389</span>     </span><span class="COMM">// load data!</span><span class="WHIT">
<span class='line'>390</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">config.datasets.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">        </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// deal with closure issues</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">config.datasets</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">loaderClass</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">            </span><span class="COMM">// support some older syntax</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">            </span><span class="NAME">options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.data</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">data.options</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">            </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.type</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">options.type</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT">            </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">loadManager.increment</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>397</span> </span><span class="WHIT">            </span><span class="COMM">// get loader class</span><span class="WHIT">
<span class='line'>398</span> </span><span class="WHIT">            </span><span class="NAME">loaderClass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">TimeMap.loaders</span><span class="PUNC">[</span><span class="NAME">type</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>399</span> </span><span class="WHIT">            </span><span class="COMM">// load with appropriate loader</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT">            </span><span class="NAME">loader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">loaderClass</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>401</span> </span><span class="WHIT">            </span><span class="NAME">loader.load</span><span class="PUNC">(</span><span class="NAME">datasets</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>402</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>403</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>404</span> </span><span class="WHIT">    </span><span class="COMM">// return timemap object for later manipulation</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">tm</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>406</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>407</span> 
<span class='line'>408</span> </span><span class="COMM">/**
<span class='line'>409</span>  * @class Static singleton for managing multiple asynchronous loads
<span class='line'>410</span>  */</span><span class="WHIT">
<span class='line'>411</span> </span><span class="NAME">TimeMap.loadManager</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>412</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">mgr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>413</span> </span><span class="WHIT">    
<span class='line'>414</span>     </span><span class="COMM">/**
<span class='line'>415</span>      * Initialize (or reset) the load manager
<span class='line'>416</span>      * @name TimeMap.loadManager#init
<span class='line'>417</span>      * @function
<span class='line'>418</span>      *
<span class='line'>419</span>      * @param {TimeMap} tm          TimeMap instance
<span class='line'>420</span>      * @param {Number} target       Number of datasets we're loading
<span class='line'>421</span>      * @param {Object} [options]    Container for optional settings
<span class='line'>422</span>      * @param {Function} [options.dataLoadedFunction]
<span class='line'>423</span>      *                                      Custom function replacing default completion function;
<span class='line'>424</span>      *                                      should take one parameter, the TimeMap object
<span class='line'>425</span>      * @param {String|Date} [options.scrollTo]
<span class='line'>426</span>      *                                      Where to scroll the timeline when load is complete
<span class='line'>427</span>      *                                      Options: "earliest", "latest", "now", date string, Date
<span class='line'>428</span>      * @param {Function} [options.dataDisplayedFunction]   
<span class='line'>429</span>      *                                      Custom function to fire once data is loaded and displayed;
<span class='line'>430</span>      *                                      should take one parameter, the TimeMap object
<span class='line'>431</span>      */</span><span class="WHIT">
<span class='line'>432</span> </span><span class="WHIT">    </span><span class="NAME">mgr.init</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">tm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">config</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>433</span> </span><span class="WHIT">        </span><span class="NAME">mgr.count</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT">        </span><span class="NAME">mgr.tm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tm</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>435</span> </span><span class="WHIT">        </span><span class="NAME">mgr.target</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">target</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>436</span> </span><span class="WHIT">        </span><span class="NAME">mgr.opts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">config</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>438</span> </span><span class="WHIT">    
<span class='line'>439</span>     </span><span class="COMM">/**
<span class='line'>440</span>      * Increment the count of loaded datasets
<span class='line'>441</span>      * @name TimeMap.loadManager#increment
<span class='line'>442</span>      * @function
<span class='line'>443</span>      */</span><span class="WHIT">
<span class='line'>444</span> </span><span class="WHIT">    </span><span class="NAME">mgr.increment</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>445</span> </span><span class="WHIT">        </span><span class="NAME">mgr.count</span><span class="PUNC">++</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>446</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">mgr.count</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NAME">mgr.target</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>447</span> </span><span class="WHIT">            </span><span class="NAME">mgr.complete</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>448</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>449</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>450</span> </span><span class="WHIT">    
<span class='line'>451</span>     </span><span class="COMM">/**
<span class='line'>452</span>      * Function to fire when all loads are complete. 
<span class='line'>453</span>      * Default behavior is to scroll to a given date (if provided) and
<span class='line'>454</span>      * layout the timeline.
<span class='line'>455</span>      * @name TimeMap.loadManager#complete
<span class='line'>456</span>      * @function
<span class='line'>457</span>      */</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT">    </span><span class="NAME">mgr.complete</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>459</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mgr.tm</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>460</span> </span><span class="WHIT">            </span><span class="NAME">opts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mgr.opts</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>461</span> </span><span class="WHIT">            </span><span class="COMM">// custom function including timeline scrolling and layout</span><span class="WHIT">
<span class='line'>462</span> </span><span class="WHIT">            </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opts.dataLoadedFunction</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">func</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>464</span> </span><span class="WHIT">            </span><span class="NAME">func</span><span class="PUNC">(</span><span class="NAME">tm</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>465</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> 
<span class='line'>466</span>         </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT">            </span><span class="NAME">tm.scrollToDate</span><span class="PUNC">(</span><span class="NAME">opts.scrollTo</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>468</span> </span><span class="WHIT">            </span><span class="COMM">// check for state support</span><span class="WHIT">
<span class='line'>469</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tm.initState</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">tm.initState</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>470</span> </span><span class="WHIT">            </span><span class="COMM">// custom function to be called when data is loaded</span><span class="WHIT">
<span class='line'>471</span> </span><span class="WHIT">            </span><span class="NAME">func</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opts.dataDisplayedFunction</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>472</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">func</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">func</span><span class="PUNC">(</span><span class="NAME">tm</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>473</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>474</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>475</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>476</span> 
<span class='line'>477</span> </span><span class="COMM">/**
<span class='line'>478</span>  * Parse a date in the context of the timeline. Uses the standard parser
<span class='line'>479</span>  * ({@link TimeMapDataset.hybridParser}) but accepts "now", "earliest", 
<span class='line'>480</span>  * "latest", "first", and "last" (referring to loaded events)
<span class='line'>481</span>  *
<span class='line'>482</span>  * @param {String|Date} s   String (or date) to parse
<span class='line'>483</span>  * @return {Date}           Parsed date
<span class='line'>484</span>  */</span><span class="WHIT">
<span class='line'>485</span> </span><span class="NAME">TimeMap.prototype.parseDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>486</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT">        </span><span class="NAME">eventSource</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.eventSource</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>488</span> </span><span class="WHIT">        </span><span class="NAME">parser</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMapDataset.hybridParser</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>489</span> </span><span class="WHIT">        </span><span class="COMM">// make sure there are events to scroll to</span><span class="WHIT">
<span class='line'>490</span> </span><span class="WHIT">        </span><span class="NAME">hasEvents</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eventSource.getCount</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>491</span> </span><span class="WHIT">    </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>492</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"now"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>493</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>494</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"earliest"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>495</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"first"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hasEvents</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>497</span> </span><span class="WHIT">                </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eventSource.getEarliestDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>498</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>499</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>500</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"latest"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>501</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">"last"</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">hasEvents</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>503</span> </span><span class="WHIT">                </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eventSource.getLatestDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>504</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>505</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>506</span> </span><span class="WHIT">        </span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>507</span> </span><span class="WHIT">            </span><span class="COMM">// assume it's a date, try to parse</span><span class="WHIT">
<span class='line'>508</span> </span><span class="WHIT">            </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parser</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>509</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>510</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>511</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>512</span> 
<span class='line'>513</span> </span><span class="COMM">/**
<span class='line'>514</span>  * Scroll the timeline to a given date. If lazyLayout is specified, this function
<span class='line'>515</span>  * will also call timeline.layout(), but only if it won't be called by the 
<span class='line'>516</span>  * onScroll listener. This involves a certain amount of reverse engineering,
<span class='line'>517</span>  * and may not be future-proof.
<span class='line'>518</span>  *
<span class='line'>519</span>  * @param {String|Date} d           Date to scroll to (either a date object, a 
<span class='line'>520</span>  *                                  date string, or one of the strings accepted 
<span class='line'>521</span>  *                                  by TimeMap#parseDate)
<span class='line'>522</span>  * @param {Boolean} [lazyLayout]    Whether to call timeline.layout() if not
<span class='line'>523</span>  *                                  required by the scroll.
<span class='line'>524</span>  */</span><span class="WHIT">
<span class='line'>525</span> </span><span class="NAME">TimeMap.prototype.scrollToDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">lazyLayout</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>526</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.parseDate</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>527</span>         </span><span class="NAME">timeline</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.timeline</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>528</span> </span><span class="WHIT">        </span><span class="NAME">layouts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>529</span> </span><span class="WHIT">        </span><span class="NAME">band</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">minTime</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">maxTime</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>530</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>531</span> </span><span class="WHIT">        </span><span class="COMM">// check which bands will need layout after scroll</span><span class="WHIT">
<span class='line'>532</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">timeline.getBandCount</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>533</span> </span><span class="WHIT">            </span><span class="NAME">band</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">timeline.getBand</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>534</span> </span><span class="WHIT">            </span><span class="NAME">minTime</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">band.getMinDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>535</span> </span><span class="WHIT">            </span><span class="NAME">maxTime</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">band.getMaxDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>536</span> </span><span class="WHIT">            </span><span class="NAME">layouts</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">lazyLayout</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">d.getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">minTime</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">d.getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">maxTime</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>537</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>538</span> </span><span class="WHIT">        </span><span class="COMM">// do scroll</span><span class="WHIT">
<span class='line'>539</span> </span><span class="WHIT">        </span><span class="NAME">timeline.getBand</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">setCenterVisibleDate</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>540</span> </span><span class="WHIT">        </span><span class="COMM">// layout as necessary</span><span class="WHIT">
<span class='line'>541</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">layouts.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>542</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">layouts</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>543</span> </span><span class="WHIT">                </span><span class="NAME">timeline.getBand</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">layout</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>544</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>545</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>546</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> 
<span class='line'>547</span>     </span><span class="COMM">// layout if requested even if no date is found</span><span class="WHIT">
<span class='line'>548</span> </span><span class="WHIT">    </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">lazyLayout</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>549</span> </span><span class="WHIT">        </span><span class="NAME">timeline.layout</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>550</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>551</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>552</span> 
<span class='line'>553</span> </span><span class="COMM">/**
<span class='line'>554</span>  * Create an empty dataset object and add it to the timemap
<span class='line'>555</span>  *
<span class='line'>556</span>  * @param {String} id           The id of the dataset
<span class='line'>557</span>  * @param {Object} options      A container for optional arguments for dataset constructor -
<span class='line'>558</span>  *                              see the options passed to {@link TimeMapDataset}
<span class='line'>559</span>  * @return {TimeMapDataset}     The new dataset object    
<span class='line'>560</span>  */</span><span class="WHIT">
<span class='line'>561</span> </span><span class="NAME">TimeMap.prototype.createDataset</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>562</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>563</span> </span><span class="WHIT">        </span><span class="NAME">dataset</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapDataset</span><span class="PUNC">(</span><span class="NAME">tm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>564</span> </span><span class="WHIT">    </span><span class="NAME">tm.datasets</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataset</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>565</span> </span><span class="WHIT">    </span><span class="COMM">// add event listener</span><span class="WHIT">
<span class='line'>566</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tm.opts.centerOnItems</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>567</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">map</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tm.map</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>568</span>             </span><span class="NAME">bounds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tm.mapBounds</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>569</span> </span><span class="WHIT">        </span><span class="NAME">GEvent.addListener</span><span class="PUNC">(</span><span class="NAME">dataset</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'itemsloaded'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>570</span> </span><span class="WHIT">            </span><span class="COMM">// determine the center and zoom level from the bounds</span><span class="WHIT">
<span class='line'>571</span> </span><span class="WHIT">            </span><span class="NAME">map.setCenter</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>572</span> </span><span class="WHIT">                </span><span class="NAME">bounds.getCenter</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>573</span> </span><span class="WHIT">                </span><span class="NAME">map.getBoundsZoomLevel</span><span class="PUNC">(</span><span class="NAME">bounds</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>574</span> </span><span class="WHIT">            </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>575</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>576</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>577</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">dataset</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>578</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>579</span> 
<span class='line'>580</span> </span><span class="COMM">/**
<span class='line'>581</span>  * Initialize the timeline - this must happen separately to allow full control of 
<span class='line'>582</span>  * timeline properties.
<span class='line'>583</span>  *
<span class='line'>584</span>  * @param {BandInfo Array} bands    Array of band information objects for timeline
<span class='line'>585</span>  */</span><span class="WHIT">
<span class='line'>586</span> </span><span class="NAME">TimeMap.prototype.initTimeline</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">bands</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>587</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>588</span> </span><span class="WHIT">        </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">painter</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>589</span> </span><span class="WHIT">    
<span class='line'>590</span>     </span><span class="COMM">// synchronize & highlight timeline bands</span><span class="WHIT">
<span class='line'>591</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">bands.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>592</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tm.opts.syncBands</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>593</span> </span><span class="WHIT">            </span><span class="NAME">bands</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">syncWith</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>594</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>595</span> </span><span class="WHIT">        </span><span class="NAME">bands</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">highlight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>596</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>597</span> </span><span class="WHIT">    
<span class='line'>598</span>     </span><span class="COMM">/** 
<span class='line'>599</span>      * The associated timeline object 
<span class='line'>600</span>      * @name TimeMap#timeline
<span class='line'>601</span>      * @type Timeline 
<span class='line'>602</span>      */</span><span class="WHIT">
<span class='line'>603</span> </span><span class="WHIT">    </span><span class="NAME">tm.timeline</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Timeline.create</span><span class="PUNC">(</span><span class="NAME">tm.tElement</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">bands</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>604</span> </span><span class="WHIT">    
<span class='line'>605</span>     </span><span class="COMM">// set event listeners</span><span class="WHIT">
<span class='line'>606</span> </span><span class="WHIT">    
<span class='line'>607</span>     </span><span class="COMM">// update map on timeline scroll</span><span class="WHIT">
<span class='line'>608</span> </span><span class="WHIT">    </span><span class="NAME">tm.timeline.getBand</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">addOnScrollListener</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>609</span> </span><span class="WHIT">        </span><span class="NAME">tm.filter</span><span class="PUNC">(</span><span class="STRN">"map"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>610</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>611</span> 
<span class='line'>612</span> </span><span class="WHIT">    </span><span class="COMM">// hijack timeline popup window to open info window</span><span class="WHIT">
<span class='line'>613</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">tm.timeline.getBandCount</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>614</span> </span><span class="WHIT">        </span><span class="NAME">painter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tm.timeline.getBand</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getEventPainter</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">constructor</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>615</span> </span><span class="WHIT">        </span><span class="NAME">painter.prototype._showBubble</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">xx</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">yy</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">evt</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>616</span> </span><span class="WHIT">            </span><span class="NAME">evt.item.openInfoWindow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>617</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>618</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>619</span> </span><span class="WHIT">    
<span class='line'>620</span>     </span><span class="COMM">// filter chain for map placemarks</span><span class="WHIT">
<span class='line'>621</span> </span><span class="WHIT">    </span><span class="NAME">tm.addFilterChain</span><span class="PUNC">(</span><span class="STRN">"map"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>622</span>         </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>623</span> </span><span class="WHIT">            </span><span class="NAME">item.showPlacemark</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>624</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>625</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>626</span> </span><span class="WHIT">            </span><span class="NAME">item.hidePlacemark</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>627</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>628</span> </span><span class="WHIT">    </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>629</span> </span><span class="WHIT">    
<span class='line'>630</span>     </span><span class="COMM">// filter: hide when item is hidden</span><span class="WHIT">
<span class='line'>631</span> </span><span class="WHIT">    </span><span class="NAME">tm.addFilter</span><span class="PUNC">(</span><span class="STRN">"map"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>632</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">item.visible</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>633</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>634</span> </span><span class="WHIT">    </span><span class="COMM">// filter: hide when dataset is hidden</span><span class="WHIT">
<span class='line'>635</span> </span><span class="WHIT">    </span><span class="NAME">tm.addFilter</span><span class="PUNC">(</span><span class="STRN">"map"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>636</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">item.dataset.visible</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>637</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>638</span> </span><span class="WHIT">    
<span class='line'>639</span>     </span><span class="COMM">// filter: hide map items depending on timeline state</span><span class="WHIT">
<span class='line'>640</span> </span><span class="WHIT">    </span><span class="NAME">tm.addFilter</span><span class="PUNC">(</span><span class="STRN">"map"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tm.opts.mapFilter</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>641</span> </span><span class="WHIT">    
<span class='line'>642</span>     </span><span class="COMM">// filter chain for timeline events</span><span class="WHIT">
<span class='line'>643</span> </span><span class="WHIT">    </span><span class="NAME">tm.addFilterChain</span><span class="PUNC">(</span><span class="STRN">"timeline"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>644</span>         </span><span class="COMM">// on</span><span class="WHIT">
<span class='line'>645</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>646</span> </span><span class="WHIT">            </span><span class="NAME">item.showEvent</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>647</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>648</span> </span><span class="WHIT">        </span><span class="COMM">// off</span><span class="WHIT">
<span class='line'>649</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>650</span> </span><span class="WHIT">            </span><span class="NAME">item.hideEvent</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>651</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>652</span> </span><span class="WHIT">        </span><span class="COMM">// pre</span><span class="WHIT">
<span class='line'>653</span> </span><span class="WHIT">        </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>654</span> </span><span class="WHIT">        </span><span class="COMM">// post</span><span class="WHIT">
<span class='line'>655</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>656</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.timemap</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>657</span> </span><span class="WHIT">            </span><span class="NAME">tm.eventSource._events._index</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>658</span> </span><span class="WHIT">            </span><span class="NAME">tm.timeline.layout</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>659</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>660</span> </span><span class="WHIT">    </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>661</span> </span><span class="WHIT">    
<span class='line'>662</span>     </span><span class="COMM">// filter: hide when item is hidden</span><span class="WHIT">
<span class='line'>663</span> </span><span class="WHIT">    </span><span class="NAME">tm.addFilter</span><span class="PUNC">(</span><span class="STRN">"timeline"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>664</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">item.visible</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>665</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>666</span> </span><span class="WHIT">    </span><span class="COMM">// filter: hide when dataset is hidden</span><span class="WHIT">
<span class='line'>667</span> </span><span class="WHIT">    </span><span class="NAME">tm.addFilter</span><span class="PUNC">(</span><span class="STRN">"timeline"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>668</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">item.dataset.visible</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>669</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>670</span> </span><span class="WHIT">    
<span class='line'>671</span>     </span><span class="COMM">// add callback for window resize</span><span class="WHIT">
<span class='line'>672</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">resizeTimerID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>673</span> </span><span class="WHIT">        </span><span class="NAME">timeline</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tm.timeline</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>674</span> </span><span class="WHIT">    </span><span class="NAME">window.onresize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>675</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">resizeTimerID</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>676</span> </span><span class="WHIT">            </span><span class="NAME">resizeTimerID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.setTimeout</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>677</span> </span><span class="WHIT">                </span><span class="NAME">resizeTimerID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>678</span> </span><span class="WHIT">                </span><span class="NAME">timeline.layout</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>679</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">500</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>680</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>681</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>682</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>683</span> 
<span class='line'>684</span> </span><span class="COMM">/**
<span class='line'>685</span>  * Run a function on each dataset in the timemap. This is the preferred
<span class='line'>686</span>  * iteration method, as it allows for future iterator options.
<span class='line'>687</span>  *
<span class='line'>688</span>  * @param {Function} f    The function to run, taking one dataset as an argument
<span class='line'>689</span>  */</span><span class="WHIT">
<span class='line'>690</span> </span><span class="NAME">TimeMap.prototype.each</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>691</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>692</span>         </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>693</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">tm.datasets</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>694</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tm.datasets.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>695</span> </span><span class="WHIT">            </span><span class="NAME">f</span><span class="PUNC">(</span><span class="NAME">tm.datasets</span><span class="PUNC">[</span><span class="NAME">id</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>696</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>697</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>698</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>699</span> 
<span class='line'>700</span> </span><span class="COMM">/**
<span class='line'>701</span>  * Run a function on each item in each dataset in the timemap.
<span class='line'>702</span>  *
<span class='line'>703</span>  * @param {Function} f    The function to run, taking one item as an argument
<span class='line'>704</span>  */</span><span class="WHIT">
<span class='line'>705</span> </span><span class="NAME">TimeMap.prototype.eachItem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>706</span> </span><span class="WHIT">    </span><span class="NAME">this.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">ds</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>707</span> </span><span class="WHIT">        </span><span class="NAME">ds.each</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>708</span> </span><span class="WHIT">            </span><span class="NAME">f</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>709</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>710</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>711</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>712</span> 
<span class='line'>713</span> </span><span class="COMM">/**
<span class='line'>714</span>  * Get all items from all datasets.
<span class='line'>715</span>  *
<span class='line'>716</span>  * @return {TimeMapItem[]}  Array of all items
<span class='line'>717</span>  */</span><span class="WHIT">
<span class='line'>718</span> </span><span class="NAME">TimeMap.prototype.getItems</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>719</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">items</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>720</span> </span><span class="WHIT">    </span><span class="NAME">this.eachItem</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>721</span> </span><span class="WHIT">        </span><span class="NAME">items.push</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>722</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>723</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">items</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>724</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>725</span> 
<span class='line'>726</span> 
<span class='line'>727</span> </span><span class="COMM">/*----------------------------------------------------------------------------
<span class='line'>728</span>  * Loader namespace and base classes
<span class='line'>729</span>  *---------------------------------------------------------------------------*/</span><span class="WHIT">
<span class='line'>730</span> </span><span class="WHIT"> 
<span class='line'>731</span> </span><span class="COMM">/**
<span class='line'>732</span>  * @namespace
<span class='line'>733</span>  * Namespace for different data loader functions.
<span class='line'>734</span>  * New loaders can add their factories or constructors to this object; loader
<span class='line'>735</span>  * functions are passed an object with parameters in TimeMap.init().
<span class='line'>736</span>  *
<span class='line'>737</span>  * @example
<span class='line'>738</span>     TimeMap.init({
<span class='line'>739</span>         datasets: [
<span class='line'>740</span>             {
<span class='line'>741</span>                 // name of class in TimeMap.loaders
<span class='line'>742</span>                 type: "json_string",
<span class='line'>743</span>                 options: {
<span class='line'>744</span>                     url: "mydata.json"
<span class='line'>745</span>                 },
<span class='line'>746</span>                 // etc...
<span class='line'>747</span>             }
<span class='line'>748</span>         ],
<span class='line'>749</span>         // etc...
<span class='line'>750</span>     });
<span class='line'>751</span>  */</span><span class="WHIT">
<span class='line'>752</span> </span><span class="NAME">TimeMap.loaders</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>753</span> 
<span class='line'>754</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>755</span>      * @namespace
<span class='line'>756</span>      * Namespace for storing callback functions
<span class='line'>757</span>      * @private
<span class='line'>758</span>      */</span><span class="WHIT">
<span class='line'>759</span> </span><span class="WHIT">    </span><span class="NAME">cb</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>760</span> </span><span class="WHIT">    
<span class='line'>761</span>     </span><span class="COMM">/**
<span class='line'>762</span>      * Cancel all current load requests. In practice, this is really only
<span class='line'>763</span>      * applicable to remote asynchronous loads. Note that this doesn't cancel 
<span class='line'>764</span>      * the download of data, just the callback that loads it.
<span class='line'>765</span>      */</span><span class="WHIT">
<span class='line'>766</span> </span><span class="WHIT">    </span><span class="NAME">cancelAll</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>767</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.loaders.cb</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>768</span> </span><span class="WHIT">            </span><span class="NAME">callbackName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>769</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callbackName</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>770</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">namespace.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">callbackName</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>771</span> </span><span class="WHIT">                </span><span class="COMM">// replace with self-cancellation function</span><span class="WHIT">
<span class='line'>772</span> </span><span class="WHIT">                </span><span class="NAME">namespace</span><span class="PUNC">[</span><span class="NAME">callbackName</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>773</span> </span><span class="WHIT">                    </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">namespace</span><span class="PUNC">[</span><span class="NAME">callbackName</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>774</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>775</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>776</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>777</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>778</span> </span><span class="WHIT">    
<span class='line'>779</span>     </span><span class="COMM">/**
<span class='line'>780</span>      * Static counter for naming callback functions
<span class='line'>781</span>      * @private
<span class='line'>782</span>      * @type int
<span class='line'>783</span>      */</span><span class="WHIT">
<span class='line'>784</span> </span><span class="WHIT">    </span><span class="NAME">counter</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>785</span> 
<span class='line'>786</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>787</span>      * @class
<span class='line'>788</span>      * Abstract loader class. All loaders should inherit from this class.
<span class='line'>789</span>      *
<span class='line'>790</span>      * @constructor
<span class='line'>791</span>      * @param {Object} options          All options for the loader
<span class='line'>792</span>      * @param {Function} [options.parserFunction=Do nothing]   
<span class='line'>793</span>      *                                      Parser function to turn a string into a JavaScript array
<span class='line'>794</span>      * @param {Function} [options.preloadFunction=Do nothing]      
<span class='line'>795</span>      *                                      Function to call on data before loading
<span class='line'>796</span>      * @param {Function} [options.transformFunction=Do nothing]    
<span class='line'>797</span>      *                                      Function to call on individual items before loading
<span class='line'>798</span>      * @param {String|Date} [options.scrollTo=earliest] Date to scroll the timeline to in the default callback 
<span class='line'>799</span>      *                                                  (see {@link TimeMap#parseDate} for accepted syntax)
<span class='line'>800</span>      */</span><span class="WHIT">
<span class='line'>801</span> </span><span class="WHIT">    </span><span class="NAME">base</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>802</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dummy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>803</span> </span><span class="WHIT">            </span><span class="NAME">loader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>804</span> </span><span class="WHIT">         
<span class='line'>805</span>         </span><span class="COMM">/**
<span class='line'>806</span>          * Parser function to turn a string into a JavaScript array
<span class='line'>807</span>          * @name TimeMap.loaders.base#parse
<span class='line'>808</span>          * @function
<span class='line'>809</span>          * @parameter {String} s        String to parse
<span class='line'>810</span>          * @return {Object[]}           Array of item data
<span class='line'>811</span>          */</span><span class="WHIT">
<span class='line'>812</span> </span><span class="WHIT">        </span><span class="NAME">loader.parse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options.parserFunction</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">dummy</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>813</span> </span><span class="WHIT">        
<span class='line'>814</span>         </span><span class="COMM">/**
<span class='line'>815</span>          * Function to call on data object before loading
<span class='line'>816</span>          * @name TimeMap.loaders.base#preload
<span class='line'>817</span>          * @function
<span class='line'>818</span>          * @parameter {Object} data     Data to preload
<span class='line'>819</span>          * @return {Object[]}           Array of item data
<span class='line'>820</span>          */</span><span class="WHIT">
<span class='line'>821</span> </span><span class="WHIT">        </span><span class="NAME">loader.preload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options.preloadFunction</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">dummy</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>822</span> </span><span class="WHIT">        
<span class='line'>823</span>         </span><span class="COMM">/**
<span class='line'>824</span>          * Function to call on a single item data object before loading
<span class='line'>825</span>          * @name TimeMap.loaders.base#transform
<span class='line'>826</span>          * @function
<span class='line'>827</span>          * @parameter {Object} data     Data to transform
<span class='line'>828</span>          * @return {Object}             Transformed data for one item
<span class='line'>829</span>          */</span><span class="WHIT">
<span class='line'>830</span> </span><span class="WHIT">        </span><span class="NAME">loader.transform</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options.transformFunction</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">dummy</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>831</span> </span><span class="WHIT">        
<span class='line'>832</span>         </span><span class="COMM">/**
<span class='line'>833</span>          * Date to scroll the timeline to on load
<span class='line'>834</span>          * @name TimeMap.loaders.base#scrollTo
<span class='line'>835</span>          * @default "earliest"
<span class='line'>836</span>          * @type String|Date
<span class='line'>837</span>          */</span><span class="WHIT">
<span class='line'>838</span> </span><span class="WHIT">        </span><span class="NAME">loader.scrollTo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options.scrollTo</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">"earliest"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>839</span> </span><span class="WHIT">        
<span class='line'>840</span>         </span><span class="COMM">/**
<span class='line'>841</span>          * Get the name of a callback function that can be cancelled. This callback applies the parser,
<span class='line'>842</span>          * preload, and transform functions, loads the data, then calls the user callback
<span class='line'>843</span>          * @name TimeMap.loaders.base#getCallbackName
<span class='line'>844</span>          * @function
<span class='line'>845</span>          *
<span class='line'>846</span>          * @param {TimeMapDataset} dataset  Dataset to load data into
<span class='line'>847</span>          * @param {Function} callback       User-supplied callback function. If no function 
<span class='line'>848</span>          *                                  is supplied, the default callback will be used
<span class='line'>849</span>          * @return {String}                 The name of the callback function in TimeMap.loaders.cb
<span class='line'>850</span>          */</span><span class="WHIT">
<span class='line'>851</span> </span><span class="WHIT">        </span><span class="NAME">loader.getCallbackName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataset</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>852</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">callbacks</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.loaders.cb</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>853</span> </span><span class="WHIT">                </span><span class="COMM">// Define a unique function name</span><span class="WHIT">
<span class='line'>854</span> </span><span class="WHIT">                </span><span class="NAME">callbackName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"_"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">TimeMap.loaders.counter</span><span class="PUNC">++</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>855</span> </span><span class="WHIT">                </span><span class="COMM">// Define default callback</span><span class="WHIT">
<span class='line'>856</span> </span><span class="WHIT">                </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>857</span> </span><span class="WHIT">                    </span><span class="NAME">dataset.timemap.scrollToDate</span><span class="PUNC">(</span><span class="NAME">loader.scrollTo</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>858</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>859</span> </span><span class="WHIT">            
<span class='line'>860</span>             </span><span class="COMM">// create callback</span><span class="WHIT">
<span class='line'>861</span> </span><span class="WHIT">            </span><span class="NAME">callbacks</span><span class="PUNC">[</span><span class="NAME">callbackName</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">result</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>862</span> </span><span class="WHIT">                </span><span class="COMM">// parse</span><span class="WHIT">
<span class='line'>863</span> </span><span class="WHIT">                </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">items</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">loader.parse</span><span class="PUNC">(</span><span class="NAME">result</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>864</span> </span><span class="WHIT">                </span><span class="COMM">// preload</span><span class="WHIT">
<span class='line'>865</span> </span><span class="WHIT">                </span><span class="NAME">items</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">loader.preload</span><span class="PUNC">(</span><span class="NAME">items</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>866</span> </span><span class="WHIT">                </span><span class="COMM">// load</span><span class="WHIT">
<span class='line'>867</span> </span><span class="WHIT">                </span><span class="NAME">dataset.loadItems</span><span class="PUNC">(</span><span class="NAME">items</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">loader.transform</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>868</span> </span><span class="WHIT">                </span><span class="COMM">// callback</span><span class="WHIT">
<span class='line'>869</span> </span><span class="WHIT">                </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> 
<span class='line'>870</span>                 </span><span class="COMM">// delete the callback function</span><span class="WHIT">
<span class='line'>871</span> </span><span class="WHIT">                </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">callbacks</span><span class="PUNC">[</span><span class="NAME">callbackName</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>872</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>873</span> </span><span class="WHIT">            
<span class='line'>874</span>             </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">callbackName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>875</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>876</span> </span><span class="WHIT">        
<span class='line'>877</span>         </span><span class="COMM">/**
<span class='line'>878</span>          * Get a callback function that can be cancelled. This is a convenience function
<span class='line'>879</span>          * to be used if the callback name itself is not needed.
<span class='line'>880</span>          * @name TimeMap.loaders.base#getCallback 
<span class='line'>881</span>          * @function
<span class='line'>882</span>          * @see TimeMap.loaders.base#getCallbackName
<span class='line'>883</span>          *
<span class='line'>884</span>          * @param {TimeMapDataset} dataset  Dataset to load data into
<span class='line'>885</span>          * @param {Function} callback       User-supplied callback function
<span class='line'>886</span>          * @return {Function}               The configured callback function
<span class='line'>887</span>          */</span><span class="WHIT">
<span class='line'>888</span> </span><span class="WHIT">        </span><span class="NAME">loader.getCallback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataset</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>889</span> </span><span class="WHIT">            </span><span class="COMM">// get loader callback name</span><span class="WHIT">
<span class='line'>890</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">callbackName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">loader.getCallbackName</span><span class="PUNC">(</span><span class="NAME">dataset</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>891</span> </span><span class="WHIT">            </span><span class="COMM">// return the function</span><span class="WHIT">
<span class='line'>892</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">TimeMap.loaders.cb</span><span class="PUNC">[</span><span class="NAME">callbackName</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>893</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>894</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>895</span> 
<span class='line'>896</span>     </span><span class="COMM">/**
<span class='line'>897</span>      * @class
<span class='line'>898</span>      * Basic loader class, for pre-loaded data. 
<span class='line'>899</span>      * Other types of loaders should take the same parameter.
<span class='line'>900</span>      *
<span class='line'>901</span>      * @augments TimeMap.loaders.base
<span class='line'>902</span>      * @example
<span class='line'>903</span> TimeMap.init({
<span class='line'>904</span>     datasets: [
<span class='line'>905</span>         {
<span class='line'>906</span>             type: "basic",
<span class='line'>907</span>             options: {
<span class='line'>908</span>                 data: [
<span class='line'>909</span>                     // object literals for each item
<span class='line'>910</span>                     {
<span class='line'>911</span>                         title: "My Item",
<span class='line'>912</span>                         start: "2009-10-06",
<span class='line'>913</span>                         point: {
<span class='line'>914</span>                             lat: 37.824,
<span class='line'>915</span>                             lon: -122.256
<span class='line'>916</span>                         }
<span class='line'>917</span>                     },
<span class='line'>918</span>                     // etc...
<span class='line'>919</span>                 ]
<span class='line'>920</span>             }
<span class='line'>921</span>         }
<span class='line'>922</span>     ],
<span class='line'>923</span>     // etc...
<span class='line'>924</span> });
<span class='line'>925</span>      * @see &lt;a href="../../examples/basic.html">Basic Example&lt;/a>
<span class='line'>926</span>      *
<span class='line'>927</span>      * @constructor
<span class='line'>928</span>      * @param {Object} options          All options for the loader
<span class='line'>929</span>      * @param {Array} options.data          Array of items to load
<span class='line'>930</span>      * @param {mixed} [options[...]]        Other options (see {@link TimeMap.loaders.base})
<span class='line'>931</span>      */</span><span class="WHIT">
<span class='line'>932</span> </span><span class="WHIT">    </span><span class="NAME">basic</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>933</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMap.loaders.base</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>934</span> </span><span class="WHIT">        
<span class='line'>935</span>         </span><span class="COMM">/**
<span class='line'>936</span>          * Array of item data to load.
<span class='line'>937</span>          * @name TimeMap.loaders.basic#data
<span class='line'>938</span>          * @default []
<span class='line'>939</span>          * @type Object[]
<span class='line'>940</span>          */</span><span class="WHIT">
<span class='line'>941</span> </span><span class="WHIT">        </span><span class="NAME">loader.data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options.items</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> 
<span class='line'>942</span>             </span><span class="COMM">// allow "value" for backwards compatibility</span><span class="WHIT">
<span class='line'>943</span> </span><span class="WHIT">            </span><span class="NAME">options.value</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>944</span> 
<span class='line'>945</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>946</span>          * Load javascript literal data.
<span class='line'>947</span>          * New loaders should implement a load function with the same signature.
<span class='line'>948</span>          * @name TimeMap.loaders.basic#load
<span class='line'>949</span>          * @function
<span class='line'>950</span>          *
<span class='line'>951</span>          * @param {TimeMapDataset} dataset  Dataset to load data into
<span class='line'>952</span>          * @param {Function} callback       Function to call once data is loaded
<span class='line'>953</span>          */</span><span class="WHIT">
<span class='line'>954</span> </span><span class="WHIT">        </span><span class="NAME">loader.load</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataset</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>955</span> </span><span class="WHIT">            </span><span class="COMM">// get callback function and call immediately on data</span><span class="WHIT">
<span class='line'>956</span> </span><span class="WHIT">            </span><span class="PUNC">(</span><span class="NAME">this.getCallback</span><span class="PUNC">(</span><span class="NAME">dataset</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="NAME">this.data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>957</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>958</span> </span><span class="WHIT">        
<span class='line'>959</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>960</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>961</span> 
<span class='line'>962</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>963</span>      * @class
<span class='line'>964</span>      * Generic class for loading remote data with a custom parser function
<span class='line'>965</span>      *
<span class='line'>966</span>      * @augments TimeMap.loaders.base
<span class='line'>967</span>      *
<span class='line'>968</span>      * @constructor
<span class='line'>969</span>      * @param {Object} options          All options for the loader
<span class='line'>970</span>      * @param {String} options.url          URL of file to load (NB: must be local address)
<span class='line'>971</span>      * @param {mixed} [options[...]]        Other options (see {@link TimeMap.loaders.base})
<span class='line'>972</span>      */</span><span class="WHIT">
<span class='line'>973</span> </span><span class="WHIT">    </span><span class="NAME">remote</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>974</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMap.loaders.base</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>975</span> </span><span class="WHIT">        
<span class='line'>976</span>         </span><span class="COMM">/**
<span class='line'>977</span>          * URL to load
<span class='line'>978</span>          * @name TimeMap.loaders.remote#url
<span class='line'>979</span>          * @type String
<span class='line'>980</span>          */</span><span class="WHIT">
<span class='line'>981</span> </span><span class="WHIT">        </span><span class="NAME">loader.url</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options.url</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>982</span> </span><span class="WHIT">        
<span class='line'>983</span>         </span><span class="COMM">/**
<span class='line'>984</span>          * Load function for remote files.
<span class='line'>985</span>          * @name TimeMap.loaders.remote#load
<span class='line'>986</span>          * @function
<span class='line'>987</span>          *
<span class='line'>988</span>          * @param {TimeMapDataset} dataset  Dataset to load data into
<span class='line'>989</span>          * @param {Function} callback       Function to call once data is loaded
<span class='line'>990</span>          */</span><span class="WHIT">
<span class='line'>991</span> </span><span class="WHIT">        </span><span class="NAME">loader.load</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataset</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>992</span> </span><span class="WHIT">            </span><span class="COMM">// download remote data and pass to callback</span><span class="WHIT">
<span class='line'>993</span> </span><span class="WHIT">            </span><span class="NAME">GDownloadUrl</span><span class="PUNC">(</span><span class="NAME">this.url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.getCallback</span><span class="PUNC">(</span><span class="NAME">dataset</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>994</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>995</span> </span><span class="WHIT">        
<span class='line'>996</span>         </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>997</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>998</span> </span><span class="WHIT">    
<span class='line'>999</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1000</span> 
<span class='line'>1001</span> </span><span class="COMM">/*----------------------------------------------------------------------------
<span class='line'>1002</span>  * TimeMapFilterChain Class
<span class='line'>1003</span>  *---------------------------------------------------------------------------*/</span><span class="WHIT">
<span class='line'>1004</span> </span><span class="WHIT"> 
<span class='line'>1005</span> </span><span class="COMM">/**
<span class='line'>1006</span>  * @class
<span class='line'>1007</span>  * TimeMapFilterChains hold a set of filters to apply to the map or timeline.
<span class='line'>1008</span>  *
<span class='line'>1009</span>  * @constructor
<span class='line'>1010</span>  * @param {TimeMap} timemap Reference to the timemap object
<span class='line'>1011</span>  * @param {Function} fon    Function to run on an item if filter is true
<span class='line'>1012</span>  * @param {Function} foff   Function to run on an item if filter is false
<span class='line'>1013</span>  * @param {Function} [pre]  Function to run before the filter runs
<span class='line'>1014</span>  * @param {Function} [post] Function to run after the filter runs
<span class='line'>1015</span>  */</span><span class="WHIT">
<span class='line'>1016</span> </span><span class="NAME">TimeMapFilterChain</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">timemap</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fon</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">foff</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pre</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">post</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1017</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1018</span> </span><span class="WHIT">        </span><span class="NAME">dummy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1019</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>1020</span>      * Reference to parent TimeMap
<span class='line'>1021</span>      * @name TimeMapFilterChain#timemap
<span class='line'>1022</span>      * @type TimeMap
<span class='line'>1023</span>      */</span><span class="WHIT">
<span class='line'>1024</span> </span><span class="WHIT">    </span><span class="NAME">fc.timemap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">timemap</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1025</span> </span><span class="WHIT">    
<span class='line'>1026</span>     </span><span class="COMM">/** 
<span class='line'>1027</span>      * Chain of filter functions, each taking an item and returning a boolean
<span class='line'>1028</span>      * @name TimeMapFilterChain#chain
<span class='line'>1029</span>      * @type Function[]
<span class='line'>1030</span>      */</span><span class="WHIT">
<span class='line'>1031</span> </span><span class="WHIT">    </span><span class="NAME">fc.chain</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1032</span> </span><span class="WHIT">    
<span class='line'>1033</span>     </span><span class="COMM">/** 
<span class='line'>1034</span>      * Function to run on an item if filter is true
<span class='line'>1035</span>      * @name TimeMapFilterChain#on
<span class='line'>1036</span>      * @function
<span class='line'>1037</span>      */</span><span class="WHIT">
<span class='line'>1038</span> </span><span class="WHIT">    </span><span class="NAME">fc.on</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fon</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">dummy</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1039</span> </span><span class="WHIT">    
<span class='line'>1040</span>     </span><span class="COMM">/** 
<span class='line'>1041</span>      * Function to run on an item if filter is false
<span class='line'>1042</span>      * @name TimeMapFilterChain#off
<span class='line'>1043</span>      * @function
<span class='line'>1044</span>      */</span><span class="WHIT">
<span class='line'>1045</span> </span><span class="WHIT">    </span><span class="NAME">fc.off</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">foff</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">dummy</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1046</span> </span><span class="WHIT">    
<span class='line'>1047</span>     </span><span class="COMM">/** 
<span class='line'>1048</span>      * Function to run before the filter runs
<span class='line'>1049</span>      * @name TimeMapFilterChain#pre
<span class='line'>1050</span>      * @function
<span class='line'>1051</span>      */</span><span class="WHIT">
<span class='line'>1052</span> </span><span class="WHIT">    </span><span class="NAME">fc.pre</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pre</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">dummy</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1053</span> </span><span class="WHIT">    
<span class='line'>1054</span>     </span><span class="COMM">/** 
<span class='line'>1055</span>      * Function to run after the filter runs
<span class='line'>1056</span>      * @name TimeMapFilterChain#post
<span class='line'>1057</span>      * @function
<span class='line'>1058</span>      */</span><span class="WHIT">
<span class='line'>1059</span> </span><span class="WHIT">    </span><span class="NAME">fc.post</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">post</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">dummy</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1060</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1061</span> 
<span class='line'>1062</span> </span><span class="COMM">/**
<span class='line'>1063</span>  * Add a filter to the filter chain.
<span class='line'>1064</span>  *
<span class='line'>1065</span>  * @param {Function} f      Function to add
<span class='line'>1066</span>  */</span><span class="WHIT">
<span class='line'>1067</span> </span><span class="NAME">TimeMapFilterChain.prototype.add</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1068</span> </span><span class="WHIT">    </span><span class="NAME">this.chain.push</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1069</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1070</span> 
<span class='line'>1071</span> </span><span class="COMM">/**
<span class='line'>1072</span>  * Remove a filter from the filter chain
<span class='line'>1073</span>  *
<span class='line'>1074</span>  * @param {Function} [f]    Function to remove; if not supplied, the last filter 
<span class='line'>1075</span>  *                          added is removed
<span class='line'>1076</span>  */</span><span class="WHIT">
<span class='line'>1077</span> </span><span class="NAME">TimeMapFilterChain.prototype.remove</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1078</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">chain</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.chain</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1079</span> </span><span class="WHIT">        </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1080</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1081</span> </span><span class="WHIT">        </span><span class="COMM">// just remove the last filter added</span><span class="WHIT">
<span class='line'>1082</span> </span><span class="WHIT">        </span><span class="NAME">chain.pop</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1083</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1084</span> </span><span class="WHIT">    </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1085</span> </span><span class="WHIT">        </span><span class="COMM">// look for the specific filter to remove</span><span class="WHIT">
<span class='line'>1086</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">chain.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1087</span> </span><span class="WHIT">		    </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">chain</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1088</span> </span><span class="WHIT">			    </span><span class="NAME">chain.splice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1089</span> </span><span class="WHIT">		    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1090</span> </span><span class="WHIT">	    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1091</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1092</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1093</span> 
<span class='line'>1094</span> </span><span class="COMM">/**
<span class='line'>1095</span>  * Run filters on all items
<span class='line'>1096</span>  */</span><span class="WHIT">
<span class='line'>1097</span> </span><span class="NAME">TimeMapFilterChain.prototype.run</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1098</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1099</span> </span><span class="WHIT">        </span><span class="NAME">chain</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fc.chain</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1100</span> </span><span class="WHIT">    </span><span class="COMM">// early exit</span><span class="WHIT">
<span class='line'>1101</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">chain.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1102</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1103</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1104</span> </span><span class="WHIT">    </span><span class="COMM">// pre-filter function</span><span class="WHIT">
<span class='line'>1105</span> </span><span class="WHIT">    </span><span class="NAME">fc.pre</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1106</span> </span><span class="WHIT">    </span><span class="COMM">// run items through filter</span><span class="WHIT">
<span class='line'>1107</span> </span><span class="WHIT">    </span><span class="NAME">fc.timemap.eachItem</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1108</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">done</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1109</span> </span><span class="WHIT">        </span><span class="NAME">F_LOOP</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">done</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> 
<span class='line'>1110</span>             </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">chain.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1111</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">chain</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1112</span> </span><span class="WHIT">                    </span><span class="COMM">// false condition</span><span class="WHIT">
<span class='line'>1113</span> </span><span class="WHIT">                    </span><span class="NAME">fc.off</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1114</span> </span><span class="WHIT">                    </span><span class="KEYW">break</span><span class="WHIT"> </span><span class="NAME">F_LOOP</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1115</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1116</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1117</span> </span><span class="WHIT">            </span><span class="COMM">// true condition</span><span class="WHIT">
<span class='line'>1118</span> </span><span class="WHIT">            </span><span class="NAME">fc.on</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1119</span> </span><span class="WHIT">            </span><span class="NAME">done</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1120</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1121</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1122</span> </span><span class="WHIT">    </span><span class="COMM">// post-filter function</span><span class="WHIT">
<span class='line'>1123</span> </span><span class="WHIT">    </span><span class="NAME">fc.post</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1124</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1125</span> 
<span class='line'>1126</span> </span><span class="COMM">// TimeMap helper functions for dealing with filters</span><span class="WHIT">
<span class='line'>1127</span> 
<span class='line'>1128</span> </span><span class="COMM">/**
<span class='line'>1129</span>  * Update items, hiding or showing according to filters
<span class='line'>1130</span>  *
<span class='line'>1131</span>  * @param {String} fid      Filter chain to update on
<span class='line'>1132</span>  */</span><span class="WHIT">
<span class='line'>1133</span> </span><span class="NAME">TimeMap.prototype.filter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fid</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1134</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.chains</span><span class="PUNC">[</span><span class="NAME">fid</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1135</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fc</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1136</span> </span><span class="WHIT">        </span><span class="NAME">fc.run</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1137</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1138</span> </span><span class="WHIT">    
<span class='line'>1139</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1140</span> 
<span class='line'>1141</span> </span><span class="COMM">/**
<span class='line'>1142</span>  * Add a new filter chain
<span class='line'>1143</span>  *
<span class='line'>1144</span>  * @param {String} fid      Id of the filter chain
<span class='line'>1145</span>  * @param {Function} fon    Function to run on an item if filter is true
<span class='line'>1146</span>  * @param {Function} foff   Function to run on an item if filter is false
<span class='line'>1147</span>  * @param {Function} [pre]  Function to run before the filter runs
<span class='line'>1148</span>  * @param {Function} [post] Function to run after the filter runs
<span class='line'>1149</span>  */</span><span class="WHIT">
<span class='line'>1150</span> </span><span class="NAME">TimeMap.prototype.addFilterChain</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fid</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fon</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">foff</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pre</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">post</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1151</span> </span><span class="WHIT">    </span><span class="NAME">this.chains</span><span class="PUNC">[</span><span class="NAME">fid</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapFilterChain</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fon</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">foff</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pre</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">post</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1152</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1153</span> 
<span class='line'>1154</span> </span><span class="COMM">/**
<span class='line'>1155</span>  * Remove a filter chain
<span class='line'>1156</span>  *
<span class='line'>1157</span>  * @param {String} fid      Id of the filter chain
<span class='line'>1158</span>  */</span><span class="WHIT">
<span class='line'>1159</span> </span><span class="NAME">TimeMap.prototype.removeFilterChain</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fid</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1160</span> </span><span class="WHIT">    </span><span class="NAME">this.chains</span><span class="PUNC">[</span><span class="NAME">fid</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1161</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1162</span> 
<span class='line'>1163</span> </span><span class="COMM">/**
<span class='line'>1164</span>  * Add a function to a filter chain
<span class='line'>1165</span>  *
<span class='line'>1166</span>  * @param {String} fid      Id of the filter chain
<span class='line'>1167</span>  * @param {Function} f      Function to add
<span class='line'>1168</span>  */</span><span class="WHIT">
<span class='line'>1169</span> </span><span class="NAME">TimeMap.prototype.addFilter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fid</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1170</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">filterChain</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.chains</span><span class="PUNC">[</span><span class="NAME">fid</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1171</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">filterChain</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1172</span> </span><span class="WHIT">        </span><span class="NAME">filterChain.add</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1173</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1174</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1175</span> 
<span class='line'>1176</span> </span><span class="COMM">/**
<span class='line'>1177</span>  * Remove a function from a filter chain
<span class='line'>1178</span>  *
<span class='line'>1179</span>  * @param {String} fid      Id of the filter chain
<span class='line'>1180</span>  * @param {Function} [f]    The function to remove
<span class='line'>1181</span>  */</span><span class="WHIT">
<span class='line'>1182</span> </span><span class="NAME">TimeMap.prototype.removeFilter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fid</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1183</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">filterChain</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.chains</span><span class="PUNC">[</span><span class="NAME">fid</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1184</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">filterChain</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1185</span> </span><span class="WHIT">        </span><span class="NAME">filterChain.remove</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1186</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1187</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1188</span> 
<span class='line'>1189</span> </span><span class="COMM">/**
<span class='line'>1190</span>  * @namespace
<span class='line'>1191</span>  * Namespace for different filter functions. Adding new filters to this
<span class='line'>1192</span>  * object allows them to be specified by string name.
<span class='line'>1193</span>  * @example
<span class='line'>1194</span>     TimeMap.init({
<span class='line'>1195</span>         options: {
<span class='line'>1196</span>             mapFilter: "hideFuture"
<span class='line'>1197</span>         },
<span class='line'>1198</span>         // etc...
<span class='line'>1199</span>     });
<span class='line'>1200</span>  */</span><span class="WHIT">
<span class='line'>1201</span> </span><span class="NAME">TimeMap.filters</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1202</span> 
<span class='line'>1203</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>1204</span>      * Static filter function: Hide items not in the visible area of the timeline.
<span class='line'>1205</span>      *
<span class='line'>1206</span>      * @param {TimeMapItem} item    Item to test for filter
<span class='line'>1207</span>      * @return {Boolean}            Whether to show the item
<span class='line'>1208</span>      */</span><span class="WHIT">
<span class='line'>1209</span> </span><span class="WHIT">    </span><span class="NAME">hidePastFuture</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1210</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">topband</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item.timeline.getBand</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1211</span> </span><span class="WHIT">            </span><span class="NAME">maxVisibleDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">topband.getMaxVisibleDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1212</span> </span><span class="WHIT">            </span><span class="NAME">minVisibleDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">topband.getMinVisibleDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1213</span> </span><span class="WHIT">            </span><span class="NAME">itemStart</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item.getStartTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1214</span> </span><span class="WHIT">            </span><span class="NAME">itemEnd</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item.getEndTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1215</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">itemStart</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1216</span> </span><span class="WHIT">            </span><span class="COMM">// hide items in the future</span><span class="WHIT">
<span class='line'>1217</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">itemStart</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">maxVisibleDate</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>1218</span> </span><span class="WHIT">                </span><span class="COMM">// hide items in the past</span><span class="WHIT">
<span class='line'>1219</span> </span><span class="WHIT">                </span><span class="PUNC">(</span><span class="NAME">itemEnd</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">minVisibleDate</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">itemStart</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">minVisibleDate</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1220</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1221</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1222</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1223</span> 
<span class='line'>1224</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>1225</span>      * Static filter function: Hide items later than the visible area of the timeline.
<span class='line'>1226</span>      *
<span class='line'>1227</span>      * @param {TimeMapItem} item    Item to test for filter
<span class='line'>1228</span>      * @return {Boolean}            Whether to show the item
<span class='line'>1229</span>      */</span><span class="WHIT">
<span class='line'>1230</span> </span><span class="WHIT">    </span><span class="NAME">hideFuture</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1231</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">maxVisibleDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item.timeline.getBand</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getMaxVisibleDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1232</span> </span><span class="WHIT">            </span><span class="NAME">itemStart</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item.getStartTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1233</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">itemStart</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1234</span> </span><span class="WHIT">            </span><span class="COMM">// hide items in the future</span><span class="WHIT">
<span class='line'>1235</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">itemStart</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">maxVisibleDate</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1236</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1237</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1238</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1239</span> 
<span class='line'>1240</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>1241</span>      * Static filter function: Hide items not present at the exact
<span class='line'>1242</span>      * center date of the timeline (will only work for duration events).
<span class='line'>1243</span>      *
<span class='line'>1244</span>      * @param {TimeMapItem} item    Item to test for filter
<span class='line'>1245</span>      * @return {Boolean}            Whether to show the item
<span class='line'>1246</span>      */</span><span class="WHIT">
<span class='line'>1247</span> </span><span class="WHIT">    </span><span class="NAME">showMomentOnly</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1248</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">topband</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item.timeline.getBand</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1249</span> </span><span class="WHIT">            </span><span class="NAME">momentDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">topband.getCenterVisibleDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1250</span> </span><span class="WHIT">            </span><span class="NAME">itemStart</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item.getStartTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1251</span> </span><span class="WHIT">            </span><span class="NAME">itemEnd</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item.getEndTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1252</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">itemStart</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1253</span> </span><span class="WHIT">            </span><span class="COMM">// hide items in the future</span><span class="WHIT">
<span class='line'>1254</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">itemStart</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">momentDate</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>1255</span> </span><span class="WHIT">                </span><span class="COMM">// hide items in the past</span><span class="WHIT">
<span class='line'>1256</span> </span><span class="WHIT">                </span><span class="PUNC">(</span><span class="NAME">itemEnd</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">momentDate</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">itemStart</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NAME">momentDate</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1257</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1258</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1259</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1260</span> 
<span class='line'>1261</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>1262</span>      * Convenience function: Do nothing. Can be used as a setting for mapFilter
<span class='line'>1263</span>      * in TimeMap.init() options, if you don't want map items to be hidden or
<span class='line'>1264</span>      * shown based on the timeline position.
<span class='line'>1265</span>      *
<span class='line'>1266</span>      * @param {TimeMapItem} item    Item to test for filter
<span class='line'>1267</span>      * @return {Boolean}            Whether to show the item
<span class='line'>1268</span>      */</span><span class="WHIT">
<span class='line'>1269</span> </span><span class="WHIT">    </span><span class="NAME">none</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1270</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1271</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1272</span> 
<span class='line'>1273</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1274</span> 
<span class='line'>1275</span> 
<span class='line'>1276</span> </span><span class="COMM">/*----------------------------------------------------------------------------
<span class='line'>1277</span>  * TimeMapDataset Class
<span class='line'>1278</span>  *---------------------------------------------------------------------------*/</span><span class="WHIT">
<span class='line'>1279</span> 
<span class='line'>1280</span> </span><span class="COMM">/**
<span class='line'>1281</span>  * @class 
<span class='line'>1282</span>  * The TimeMapDataset object holds an array of items and dataset-level
<span class='line'>1283</span>  * options and settings, including visual themes.
<span class='line'>1284</span>  *
<span class='line'>1285</span>  * @constructor
<span class='line'>1286</span>  * @param {TimeMap} timemap         Reference to the timemap object
<span class='line'>1287</span>  * @param {Object} [options]        Object holding optional arguments
<span class='line'>1288</span>  * @param {String} [options.id]                 Key for this dataset in the datasets map
<span class='line'>1289</span>  * @param {String} [options.title]              Title of the dataset (for the legend)
<span class='line'>1290</span>  * @param {String|TimeMapTheme} [options.theme]  Theme settings.
<span class='line'>1291</span>  * @param {String|Function} [options.dateParser] Function to replace default date parser.
<span class='line'>1292</span>  * @param {String} [options.infoTemplate]        HTML template for info window content
<span class='line'>1293</span>  * @param {String} [options.templatePattern]     Regex pattern defining variable syntax in the infoTemplate
<span class='line'>1294</span>  * @param {Function} [options.openInfoWindow]    Function redefining how info window opens
<span class='line'>1295</span>  * @param {Function} [options.closeInfoWindow]   Function redefining how info window closes
<span class='line'>1296</span>  * @param {mixed} [options[...]]                Any of the options for {@link TimeMapTheme} may be set here,
<span class='line'>1297</span>  *                                              to cascade to the dataset's objects, though they can be 
<span class='line'>1298</span>  *                                              overridden at the TimeMapItem level
<span class='line'>1299</span>  */</span><span class="WHIT">
<span class='line'>1300</span> </span><span class="NAME">TimeMapDataset</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">timemap</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1301</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1302</span> </span><span class="WHIT">        </span><span class="NAME">defaults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1303</span> </span><span class="WHIT">            </span><span class="NAME">title</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="STRN">'Untitled'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1304</span> </span><span class="WHIT">            </span><span class="NAME">dateParser</span><span class="PUNC">:</span><span class="WHIT">     </span><span class="NAME">TimeMapDataset.hybridParser</span><span class="WHIT">
<span class='line'>1305</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1306</span> 
<span class='line'>1307</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>1308</span>      * Reference to parent TimeMap
<span class='line'>1309</span>      * @name TimeMapDataset#timemap
<span class='line'>1310</span>      * @type TimeMap
<span class='line'>1311</span>      */</span><span class="WHIT">
<span class='line'>1312</span> </span><span class="WHIT">    </span><span class="NAME">ds.timemap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">timemap</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1313</span> </span><span class="WHIT">    
<span class='line'>1314</span>     </span><span class="COMM">/** 
<span class='line'>1315</span>      * EventSource for timeline events
<span class='line'>1316</span>      * @name TimeMapDataset#eventSource
<span class='line'>1317</span>      * @type Timeline.EventSource
<span class='line'>1318</span>      */</span><span class="WHIT">
<span class='line'>1319</span> </span><span class="WHIT">    </span><span class="NAME">ds.eventSource</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Timeline.DefaultEventSource</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1320</span> </span><span class="WHIT">    
<span class='line'>1321</span>     </span><span class="COMM">/** 
<span class='line'>1322</span>      * Array of child TimeMapItems
<span class='line'>1323</span>      * @name TimeMapDataset#items
<span class='line'>1324</span>      * @type Array
<span class='line'>1325</span>      */</span><span class="WHIT">
<span class='line'>1326</span> </span><span class="WHIT">    </span><span class="NAME">ds.items</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1327</span> </span><span class="WHIT">    
<span class='line'>1328</span>     </span><span class="COMM">/** 
<span class='line'>1329</span>      * Whether the dataset is visible
<span class='line'>1330</span>      * @name TimeMapDataset#visible
<span class='line'>1331</span>      * @type Boolean
<span class='line'>1332</span>      */</span><span class="WHIT">
<span class='line'>1333</span> </span><span class="WHIT">    </span><span class="NAME">ds.visible</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1334</span> </span><span class="WHIT">        
<span class='line'>1335</span>     </span><span class="COMM">/** 
<span class='line'>1336</span>      * Container for optional settings passed in the "options" parameter
<span class='line'>1337</span>      * @name TimeMapDataset#opts
<span class='line'>1338</span>      * @type Object
<span class='line'>1339</span>      */</span><span class="WHIT">
<span class='line'>1340</span> </span><span class="WHIT">    </span><span class="NAME">ds.opts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.merge</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">defaults</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">timemap.opts</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1341</span> </span><span class="WHIT">    
<span class='line'>1342</span>     </span><span class="COMM">// allow date parser to be specified by key</span><span class="WHIT">
<span class='line'>1343</span> </span><span class="WHIT">    </span><span class="NAME">options.dateParser</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.lookup</span><span class="PUNC">(</span><span class="NAME">options.dateParser</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TimeMap.dateParsers</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1344</span> </span><span class="WHIT">    </span><span class="COMM">// allow theme options to be specified in options</span><span class="WHIT">
<span class='line'>1345</span> </span><span class="WHIT">    </span><span class="NAME">options.theme</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme.create</span><span class="PUNC">(</span><span class="NAME">options.theme</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1346</span> </span><span class="WHIT">    
<span class='line'>1347</span>     </span><span class="COMM">/**
<span class='line'>1348</span>      * Return an array of this dataset's items
<span class='line'>1349</span>      * @name TimeMapDataset#getItems
<span class='line'>1350</span>      * @function
<span class='line'>1351</span>      *
<span class='line'>1352</span>      * @param {Number} [index]     Index of single item to return
<span class='line'>1353</span>      * @return {TimeMapItem[]}  Single item, or array of all items if no index was supplied
<span class='line'>1354</span>      */</span><span class="WHIT">
<span class='line'>1355</span> </span><span class="WHIT">    </span><span class="NAME">ds.getItems</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">index</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1356</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">index</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1357</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">index</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">ds.items.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1358</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ds.items</span><span class="PUNC">[</span><span class="NAME">index</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1359</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1360</span> </span><span class="WHIT">            </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1361</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1362</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1363</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1364</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ds.items</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1365</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1366</span> </span><span class="WHIT">    
<span class='line'>1367</span>     </span><span class="COMM">/**
<span class='line'>1368</span>      * Return the title of the dataset
<span class='line'>1369</span>      * @name TimeMapDataset#getTitle
<span class='line'>1370</span>      * @function
<span class='line'>1371</span>      * 
<span class='line'>1372</span>      * @return {String}     Dataset title
<span class='line'>1373</span>      */</span><span class="WHIT">
<span class='line'>1374</span> </span><span class="WHIT">    </span><span class="NAME">ds.getTitle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">ds.opts.title</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1375</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1376</span> 
<span class='line'>1377</span> </span><span class="COMM">/**
<span class='line'>1378</span>  * Better Timeline Gregorian parser... shouldn't be necessary :(.
<span class='line'>1379</span>  * Gregorian dates are years with "BC" or "AD"
<span class='line'>1380</span>  *
<span class='line'>1381</span>  * @param {String} s    String to parse into a Date object
<span class='line'>1382</span>  * @return {Date}       Parsed date or null
<span class='line'>1383</span>  */</span><span class="WHIT">
<span class='line'>1384</span> </span><span class="NAME">TimeMapDataset.gregorianParser</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1385</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1386</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1387</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1388</span> </span><span class="WHIT">    </span><span class="COMM">// look for BC</span><span class="WHIT">
<span class='line'>1389</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Boolean</span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/b\.?c\.?/i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1390</span> </span><span class="WHIT">        </span><span class="COMM">// parse - parseInt will stop at non-number characters</span><span class="WHIT">
<span class='line'>1391</span> </span><span class="WHIT">        </span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1392</span> </span><span class="WHIT">        </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1393</span> </span><span class="WHIT">    </span><span class="COMM">// look for success</span><span class="WHIT">
<span class='line'>1394</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">year</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1395</span> </span><span class="WHIT">        </span><span class="COMM">// deal with BC</span><span class="WHIT">
<span class='line'>1396</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">bc</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1397</span> </span><span class="WHIT">            </span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">year</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1398</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1399</span> </span><span class="WHIT">        </span><span class="COMM">// make Date and return</span><span class="WHIT">
<span class='line'>1400</span> </span><span class="WHIT">        </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1401</span> </span><span class="WHIT">        </span><span class="NAME">d.setUTCFullYear</span><span class="PUNC">(</span><span class="NAME">year</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1402</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1403</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1404</span> </span><span class="WHIT">    </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1405</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1406</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1407</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1408</span> 
<span class='line'>1409</span> </span><span class="COMM">/**
<span class='line'>1410</span>  * Parse date strings with a series of date parser functions, until one works. 
<span class='line'>1411</span>  * In order:
<span class='line'>1412</span>  * &lt;ol>
<span class='line'>1413</span>  *  &lt;li>Date.parse() (so Date.js should work here, if it works with Timeline...)&lt;/li>
<span class='line'>1414</span>  *  &lt;li>Gregorian parser&lt;/li>
<span class='line'>1415</span>  *  &lt;li>The Timeline ISO 8601 parser&lt;/li>
<span class='line'>1416</span>  * &lt;/ol>
<span class='line'>1417</span>  *
<span class='line'>1418</span>  * @param {String} s    String to parse into a Date object
<span class='line'>1419</span>  * @return {Date}       Parsed date or null
<span class='line'>1420</span>  */</span><span class="WHIT">
<span class='line'>1421</span> </span><span class="NAME">TimeMapDataset.hybridParser</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1422</span> </span><span class="WHIT">    </span><span class="COMM">// in case we don't know if this is a string or a date</span><span class="WHIT">
<span class='line'>1423</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1424</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1425</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1426</span> </span><span class="WHIT">    </span><span class="COMM">// try native date parse and timestamp</span><span class="WHIT">
<span class='line'>1427</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"number"</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">Date.parse</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1428</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1429</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1430</span> </span><span class="WHIT">            </span><span class="COMM">// look for Gregorian dates</span><span class="WHIT">
<span class='line'>1431</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^-?\d{1,6} ?(a\.?d\.?|b\.?c\.?e?\.?|c\.?e\.?)?$/i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1432</span> </span><span class="WHIT">                </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMapDataset.gregorianParser</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1433</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> 
<span class='line'>1434</span>             </span><span class="COMM">// try ISO 8601 parse</span><span class="WHIT">
<span class='line'>1435</span> </span><span class="WHIT">            </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1436</span> </span><span class="WHIT">                </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1437</span> </span><span class="WHIT">                    </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">DateTime.parseIso8601DateTime</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1438</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1439</span> </span><span class="WHIT">                    </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1440</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1441</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1442</span> </span><span class="WHIT">            </span><span class="COMM">// look for timestamps</span><span class="WHIT">
<span class='line'>1443</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^\d{7,}$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1444</span> </span><span class="WHIT">                </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1445</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1446</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1447</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1448</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1449</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1450</span> </span><span class="WHIT">    </span><span class="COMM">// d should be a date or null</span><span class="WHIT">
<span class='line'>1451</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1452</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1453</span> 
<span class='line'>1454</span> </span><span class="COMM">/**
<span class='line'>1455</span>  * Run a function on each item in the dataset. This is the preferred
<span class='line'>1456</span>  * iteration method, as it allows for future iterator options.
<span class='line'>1457</span>  *
<span class='line'>1458</span>  * @param {Function} f    The function to run
<span class='line'>1459</span>  */</span><span class="WHIT">
<span class='line'>1460</span> </span><span class="NAME">TimeMapDataset.prototype.each</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">f</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1461</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">this.items.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1462</span> </span><span class="WHIT">        </span><span class="NAME">f</span><span class="PUNC">(</span><span class="NAME">this.items</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1463</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1464</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1465</span> 
<span class='line'>1466</span> </span><span class="COMM">/**
<span class='line'>1467</span>  * Add an array of items to the map and timeline. 
<span class='line'>1468</span>  * Each item has both a timeline event and a map placemark.
<span class='line'>1469</span>  *
<span class='line'>1470</span>  * @param {Object} data             Data to be loaded. See loadItem() for the format.
<span class='line'>1471</span>  * @param {Function} [transform]    If data is not in the above format, transformation function to make it so
<span class='line'>1472</span>  * @see TimeMapDataset#loadItem
<span class='line'>1473</span>  */</span><span class="WHIT">
<span class='line'>1474</span> </span><span class="NAME">TimeMapDataset.prototype.loadItems</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">transform</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1475</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">data.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1476</span> </span><span class="WHIT">        </span><span class="NAME">this.loadItem</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">transform</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1477</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1478</span> </span><span class="WHIT">    </span><span class="NAME">GEvent.trigger</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'itemsloaded'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1479</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1480</span> 
<span class='line'>1481</span> </span><span class="COMM">/**
<span class='line'>1482</span>  * Add one item to map and timeline. 
<span class='line'>1483</span>  * Each item has both a timeline event and a map placemark.
<span class='line'>1484</span>  *
<span class='line'>1485</span>  * @param {Object} data         Data to be loaded
<span class='line'>1486</span>  * @param {String} [data.title]         Title of the item (visible on timeline)
<span class='line'>1487</span>  * @param {String|Date} [data.start]    Start time of the event on the timeline
<span class='line'>1488</span>  * @param {String|Date} [data.end]      End time of the event on the timeline (duration events only)
<span class='line'>1489</span>  * @param {Object} [data.point]         Data for a single-point placemark: 
<span class='line'>1490</span>  * @param {Float} [data.point.lat]          Latitude of map marker
<span class='line'>1491</span>  * @param {Float} [data.point.lon]          Longitude of map marker
<span class='line'>1492</span>  * @param {Object[]} [data.polyline]    Data for a polyline placemark, as an array in "point" format
<span class='line'>1493</span>  * @param {Object[]} [data.polygon]     Data for a polygon placemark, as an array "point" format
<span class='line'>1494</span>  * @param {Object} [data.overlay]       Data for a ground overlay:
<span class='line'>1495</span>  * @param {String} [data.overlay.image]     URL of image to overlay
<span class='line'>1496</span>  * @param {Float} [data.overlay.north]      Northern latitude of the overlay
<span class='line'>1497</span>  * @param {Float} [data.overlay.south]      Southern latitude of the overlay
<span class='line'>1498</span>  * @param {Float} [data.overlay.east]       Eastern longitude of the overlay
<span class='line'>1499</span>  * @param {Float} [data.overlay.west]       Western longitude of the overlay
<span class='line'>1500</span>  * @param {Object[]} [data.placemarks]  Array of placemarks, e.g. [{point:{...}}, {polyline:[...]}]
<span class='line'>1501</span>  * @param {Object} [options]            Optional arguments - see the {@link TimeMapItem} constructor for details
<span class='line'>1502</span>  * @param {Function} [transform]        If data is not in the above format, transformation function to make it so
<span class='line'>1503</span>  * @return {TimeMapItem}                The created item (for convenience, as it's already been added)
<span class='line'>1504</span>  * @see TimeMapItem
<span class='line'>1505</span>  */</span><span class="WHIT">
<span class='line'>1506</span> </span><span class="NAME">TimeMapDataset.prototype.loadItem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">transform</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1507</span> </span><span class="WHIT">    </span><span class="COMM">// apply transformation, if any</span><span class="WHIT">
<span class='line'>1508</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">transform</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1509</span> </span><span class="WHIT">        </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">transform</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1510</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1511</span> </span><span class="WHIT">    </span><span class="COMM">// transform functions can return a null value to skip a datum in the set</span><span class="WHIT">
<span class='line'>1512</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1513</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1514</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1515</span> </span><span class="WHIT">    
<span class='line'>1516</span>     </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">ds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1517</span> </span><span class="WHIT">        </span><span class="NAME">tm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ds.timemap</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1518</span> </span><span class="WHIT">        </span><span class="COMM">// set defaults for options</span><span class="WHIT">
<span class='line'>1519</span> </span><span class="WHIT">        </span><span class="NAME">options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.merge</span><span class="PUNC">(</span><span class="NAME">data.options</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ds.opts</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1520</span> </span><span class="WHIT">        </span><span class="COMM">// allow theme options to be specified in options</span><span class="WHIT">
<span class='line'>1521</span> </span><span class="WHIT">        </span><span class="NAME">theme</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options.theme</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme.create</span><span class="PUNC">(</span><span class="NAME">options.theme</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1522</span> </span><span class="WHIT">        </span><span class="NAME">parser</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ds.opts.dateParser</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1523</span>         </span><span class="NAME">eventClass</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Timeline.DefaultEventSource.Event</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1524</span> </span><span class="WHIT">        </span><span class="COMM">// settings for timeline event</span><span class="WHIT">
<span class='line'>1525</span> </span><span class="WHIT">        </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.start</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1526</span>         </span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.end</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1527</span>         </span><span class="NAME">eventIcon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">theme.eventIcon</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1528</span> </span><span class="WHIT">        </span><span class="NAME">textColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">theme.eventTextColor</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1529</span> </span><span class="WHIT">        </span><span class="NAME">title</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.title</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1530</span> </span><span class="WHIT">        </span><span class="COMM">// allow event-less placemarks - these will be always present on map</span><span class="WHIT">
<span class='line'>1531</span> </span><span class="WHIT">        </span><span class="NAME">event</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1532</span> </span><span class="WHIT">        </span><span class="NAME">instant</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1533</span> </span><span class="WHIT">        </span><span class="COMM">// settings for the placemark</span><span class="WHIT">
<span class='line'>1534</span> </span><span class="WHIT">        </span><span class="NAME">markerIcon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">theme.icon</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1535</span> </span><span class="WHIT">        </span><span class="NAME">bounds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">tm.mapBounds</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1536</span> </span><span class="WHIT">        </span><span class="COMM">// empty containers</span><span class="WHIT">
<span class='line'>1537</span> </span><span class="WHIT">        </span><span class="NAME">placemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1538</span>         </span><span class="NAME">pdataArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1539</span>         </span><span class="NAME">pdata</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1540</span>         </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1541</span>         </span><span class="NAME">point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1542</span>         </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1543</span> </span><span class="WHIT">    
<span class='line'>1544</span>     </span><span class="COMM">// create timeline event</span><span class="WHIT">
<span class='line'>1545</span> </span><span class="WHIT">    </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">parser</span><span class="PUNC">(</span><span class="NAME">start</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1546</span> </span><span class="WHIT">    </span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">parser</span><span class="PUNC">(</span><span class="NAME">end</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1547</span> </span><span class="WHIT">    </span><span class="NAME">instant</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">end</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1548</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> 
<span class='line'>1549</span>         </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">util.TimelineVersion</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"1.2"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1550</span> </span><span class="WHIT">            </span><span class="COMM">// attributes by parameter</span><span class="WHIT">
<span class='line'>1551</span> </span><span class="WHIT">            </span><span class="NAME">event</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">eventClass</span><span class="PUNC">(</span><span class="NAME">start</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">end</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1552</span> </span><span class="WHIT">                </span><span class="NAME">instant</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">title</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">eventIcon</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">theme.eventColor</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1553</span>                 </span><span class="NAME">theme.eventTextColor</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1554</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1555</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">textColor</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1556</span> </span><span class="WHIT">                </span><span class="COMM">// tweak to show old-style events</span><span class="WHIT">
<span class='line'>1557</span> </span><span class="WHIT">                </span><span class="NAME">textColor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">theme.classicTape</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">instant</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'#FFFFFF'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'#000000'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1558</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1559</span> </span><span class="WHIT">            </span><span class="COMM">// attributes in object</span><span class="WHIT">
<span class='line'>1560</span> </span><span class="WHIT">            </span><span class="NAME">event</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">eventClass</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1561</span> </span><span class="WHIT">                </span><span class="NAME">start</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">start</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1562</span> </span><span class="WHIT">                </span><span class="NAME">end</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">end</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1563</span> </span><span class="WHIT">                </span><span class="NAME">instant</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">instant</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1564</span> </span><span class="WHIT">                </span><span class="NAME">text</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">title</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1565</span> </span><span class="WHIT">                </span><span class="NAME">icon</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">eventIcon</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1566</span> </span><span class="WHIT">                </span><span class="NAME">color</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">theme.eventColor</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1567</span> </span><span class="WHIT">                </span><span class="NAME">textColor</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">textColor</span><span class="WHIT">
<span class='line'>1568</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1569</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1570</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1571</span> </span><span class="WHIT">    
<span class='line'>1572</span>     </span><span class="COMM">// internal function: create map placemark</span><span class="WHIT">
<span class='line'>1573</span> </span><span class="WHIT">    </span><span class="COMM">// takes a data object (could be full data, could be just placemark)</span><span class="WHIT">
<span class='line'>1574</span> </span><span class="WHIT">    </span><span class="COMM">// returns an object with {placemark, type, point}</span><span class="WHIT">
<span class='line'>1575</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">createPlacemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">pdata</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1576</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">placemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1577</span>             </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1578</span>             </span><span class="NAME">point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1579</span> </span><span class="WHIT">        </span><span class="COMM">// point placemark</span><span class="WHIT">
<span class='line'>1580</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pdata.point</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1581</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">lat</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pdata.point.lat</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1582</span>                 </span><span class="NAME">lon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pdata.point.lon</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1583</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">lat</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">lon</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1584</span> </span><span class="WHIT">                </span><span class="COMM">// give up</span><span class="WHIT">
<span class='line'>1585</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1586</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1587</span> </span><span class="WHIT">            </span><span class="NAME">point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GLatLng</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1588</span> </span><span class="WHIT">                </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">pdata.point.lat</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1589</span>                 </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">pdata.point.lon</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1590</span> </span><span class="WHIT">            </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1591</span> </span><span class="WHIT">            </span><span class="COMM">// add point to visible map bounds</span><span class="WHIT">
<span class='line'>1592</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tm.opts.centerOnItems</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1593</span> </span><span class="WHIT">                </span><span class="NAME">bounds.extend</span><span class="PUNC">(</span><span class="NAME">point</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1594</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1595</span> </span><span class="WHIT">            </span><span class="COMM">// create marker</span><span class="WHIT">
<span class='line'>1596</span> </span><span class="WHIT">            </span><span class="NAME">placemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GMarker</span><span class="PUNC">(</span><span class="NAME">point</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1597</span> </span><span class="WHIT">                </span><span class="NAME">icon</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">markerIcon</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1598</span> </span><span class="WHIT">                </span><span class="NAME">title</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">pdata.title</span><span class="WHIT">
<span class='line'>1599</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1600</span> </span><span class="WHIT">            </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"marker"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1601</span> </span><span class="WHIT">            </span><span class="NAME">point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">placemark.getLatLng</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1602</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1603</span> </span><span class="WHIT">        </span><span class="COMM">// polyline and polygon placemarks</span><span class="WHIT">
<span class='line'>1604</span> </span><span class="WHIT">        </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pdata.polyline</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">pdata.polygon</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1605</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">points</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">line</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1606</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pdata.polyline</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1607</span> </span><span class="WHIT">                </span><span class="NAME">line</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pdata.polyline</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1608</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1609</span> </span><span class="WHIT">                </span><span class="NAME">line</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pdata.polygon</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1610</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1611</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">line</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">line.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1612</span> </span><span class="WHIT">                </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">&lt;</span><span class="NAME">line.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1613</span> </span><span class="WHIT">                    </span><span class="NAME">point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GLatLng</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1614</span> </span><span class="WHIT">                        </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">line</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">lat</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1615</span>                         </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">line</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">lon</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1616</span> </span><span class="WHIT">                    </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1617</span> </span><span class="WHIT">                    </span><span class="NAME">points.push</span><span class="PUNC">(</span><span class="NAME">point</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1618</span> </span><span class="WHIT">                    </span><span class="COMM">// add point to visible map bounds</span><span class="WHIT">
<span class='line'>1619</span> </span><span class="WHIT">                    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tm.opts.centerOnItems</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1620</span> </span><span class="WHIT">                        </span><span class="NAME">bounds.extend</span><span class="PUNC">(</span><span class="NAME">point</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1621</span> </span><span class="WHIT">                    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1622</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1623</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"polyline"</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">pdata</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1624</span> </span><span class="WHIT">                    </span><span class="NAME">placemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GPolyline</span><span class="PUNC">(</span><span class="NAME">points</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1625</span>                                               </span><span class="NAME">theme.lineColor</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1626</span>                                               </span><span class="NAME">theme.lineWeight</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1627</span> </span><span class="WHIT">                                              </span><span class="NAME">theme.lineOpacity</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1628</span> </span><span class="WHIT">                    </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"polyline"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1629</span> </span><span class="WHIT">                    </span><span class="NAME">point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">placemark.getVertex</span><span class="PUNC">(</span><span class="NAME">Math.floor</span><span class="PUNC">(</span><span class="NAME">placemark.getVertexCount</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1630</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1631</span> </span><span class="WHIT">                    </span><span class="NAME">placemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GPolygon</span><span class="PUNC">(</span><span class="NAME">points</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1632</span>                                              </span><span class="NAME">theme.polygonLineColor</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1633</span>                                              </span><span class="NAME">theme.polygonLineWeight</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1634</span> </span><span class="WHIT">                                             </span><span class="NAME">theme.polygonLineOpacity</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1635</span> </span><span class="WHIT">                                             </span><span class="NAME">theme.fillColor</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1636</span> </span><span class="WHIT">                                             </span><span class="NAME">theme.fillOpacity</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1637</span> </span><span class="WHIT">                    </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"polygon"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1638</span> </span><span class="WHIT">                    </span><span class="NAME">point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">placemark.getBounds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getCenter</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1639</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1640</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1641</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> 
<span class='line'>1642</span>         </span><span class="COMM">// ground overlay placemark</span><span class="WHIT">
<span class='line'>1643</span> </span><span class="WHIT">        </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"overlay"</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">pdata</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1644</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sw</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GLatLng</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1645</span> </span><span class="WHIT">                    </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">pdata.overlay.south</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1646</span>                     </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">pdata.overlay.west</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1647</span> </span><span class="WHIT">                </span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1648</span> </span><span class="WHIT">                </span><span class="NAME">ne</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GLatLng</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1649</span> </span><span class="WHIT">                    </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">pdata.overlay.north</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1650</span>                     </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">pdata.overlay.east</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1651</span> </span><span class="WHIT">                </span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1652</span> </span><span class="WHIT">                </span><span class="COMM">// create overlay</span><span class="WHIT">
<span class='line'>1653</span> </span><span class="WHIT">                </span><span class="NAME">overlayBounds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GLatLngBounds</span><span class="PUNC">(</span><span class="NAME">sw</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ne</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1654</span> </span><span class="WHIT">            </span><span class="COMM">// add to visible bounds</span><span class="WHIT">
<span class='line'>1655</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tm.opts.centerOnItems</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1656</span> </span><span class="WHIT">                </span><span class="NAME">bounds.extend</span><span class="PUNC">(</span><span class="NAME">sw</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1657</span> </span><span class="WHIT">                </span><span class="NAME">bounds.extend</span><span class="PUNC">(</span><span class="NAME">ne</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1658</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1659</span> </span><span class="WHIT">            </span><span class="NAME">placemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GGroundOverlay</span><span class="PUNC">(</span><span class="NAME">pdata.overlay.image</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">overlayBounds</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1660</span> </span><span class="WHIT">            </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"overlay"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1661</span> </span><span class="WHIT">            </span><span class="NAME">point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">overlayBounds.getCenter</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1662</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1663</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1664</span> </span><span class="WHIT">            </span><span class="STRN">"placemark"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">placemark</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1665</span> </span><span class="WHIT">            </span><span class="STRN">"type"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1666</span> </span><span class="WHIT">            </span><span class="STRN">"point"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">point</span><span class="WHIT">
<span class='line'>1667</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1668</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1669</span> </span><span class="WHIT">    
<span class='line'>1670</span>     </span><span class="COMM">// create placemark or placemarks</span><span class="WHIT">
<span class='line'>1671</span> </span><span class="WHIT">    
<span class='line'>1672</span>     </span><span class="COMM">// array of placemark objects</span><span class="WHIT">
<span class='line'>1673</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"placemarks"</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1674</span> </span><span class="WHIT">        </span><span class="NAME">pdataArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data.placemarks</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1675</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1676</span> </span><span class="WHIT">        </span><span class="COMM">// we have one or more single placemarks</span><span class="WHIT">
<span class='line'>1677</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">types</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">"point"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"polyline"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"polygon"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"overlay"</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1678</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">types.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1679</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">types</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1680</span> </span><span class="WHIT">                </span><span class="COMM">// put in title (only used for markers)</span><span class="WHIT">
<span class='line'>1681</span> </span><span class="WHIT">                </span><span class="NAME">pdata</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">title</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">title</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1682</span> </span><span class="WHIT">                </span><span class="NAME">pdata</span><span class="PUNC">[</span><span class="NAME">types</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">types</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1683</span> </span><span class="WHIT">                </span><span class="NAME">pdataArr.push</span><span class="PUNC">(</span><span class="NAME">pdata</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1684</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1685</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1686</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1687</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pdataArr</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1688</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">pdataArr.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1689</span> </span><span class="WHIT">            </span><span class="COMM">// create the placemark</span><span class="WHIT">
<span class='line'>1690</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">createPlacemark</span><span class="PUNC">(</span><span class="NAME">pdataArr</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1691</span> </span><span class="WHIT">            </span><span class="COMM">// check that the placemark was valid</span><span class="WHIT">
<span class='line'>1692</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">p.placemark</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1693</span> </span><span class="WHIT">                </span><span class="COMM">// take the first point and type as a default</span><span class="WHIT">
<span class='line'>1694</span> </span><span class="WHIT">                </span><span class="NAME">point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">point</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">p.point</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1695</span> </span><span class="WHIT">                </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">p.type</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1696</span> </span><span class="WHIT">                </span><span class="NAME">placemark.push</span><span class="PUNC">(</span><span class="NAME">p.placemark</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1697</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1698</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1699</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1700</span> </span><span class="WHIT">    </span><span class="COMM">// override type for arrays</span><span class="WHIT">
<span class='line'>1701</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">placemark.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1702</span> </span><span class="WHIT">        </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"array"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1703</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1704</span> </span><span class="WHIT">    
<span class='line'>1705</span>     </span><span class="NAME">options.title</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">title</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1706</span> </span><span class="WHIT">    </span><span class="NAME">options.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1707</span> </span><span class="WHIT">    </span><span class="COMM">// check for custom infoPoint and convert to GLatLng</span><span class="WHIT">
<span class='line'>1708</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">options.infoPoint</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1709</span> </span><span class="WHIT">        </span><span class="NAME">options.infoPoint</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GLatLng</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>1710</span> </span><span class="WHIT">            </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">options.infoPoint.lat</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>1711</span>             </span><span class="NAME">parseFloat</span><span class="PUNC">(</span><span class="NAME">options.infoPoint.lon</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>1712</span> </span><span class="WHIT">        </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1713</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1714</span> </span><span class="WHIT">        </span><span class="NAME">options.infoPoint</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">point</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1715</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1716</span> </span><span class="WHIT">    
<span class='line'>1717</span>     </span><span class="COMM">// create item and cross-references</span><span class="WHIT">
<span class='line'>1718</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapItem</span><span class="PUNC">(</span><span class="NAME">placemark</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ds</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1719</span> </span><span class="WHIT">    </span><span class="COMM">// add event if it exists</span><span class="WHIT">
<span class='line'>1720</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">event</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1721</span> </span><span class="WHIT">        </span><span class="NAME">event.item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1722</span> </span><span class="WHIT">        </span><span class="COMM">// allow for custom event loading</span><span class="WHIT">
<span class='line'>1723</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">ds.opts.noEventLoad</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1724</span> </span><span class="WHIT">            </span><span class="COMM">// add event to timeline</span><span class="WHIT">
<span class='line'>1725</span> </span><span class="WHIT">            </span><span class="NAME">ds.eventSource.add</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1726</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1727</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1728</span> </span><span class="WHIT">    </span><span class="COMM">// add placemark(s) if any exist</span><span class="WHIT">
<span class='line'>1729</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">placemark.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1730</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">placemark.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1731</span> </span><span class="WHIT">            </span><span class="NAME">placemark</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1732</span> </span><span class="WHIT">            </span><span class="COMM">// add listener to make placemark open when event is clicked</span><span class="WHIT">
<span class='line'>1733</span> </span><span class="WHIT">            </span><span class="NAME">GEvent.addListener</span><span class="PUNC">(</span><span class="NAME">placemark</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"click"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1734</span> </span><span class="WHIT">                </span><span class="NAME">item.openInfoWindow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1735</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1736</span> </span><span class="WHIT">            </span><span class="COMM">// allow for custom placemark loading</span><span class="WHIT">
<span class='line'>1737</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">ds.opts.noPlacemarkLoad</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1738</span> </span><span class="WHIT">                </span><span class="COMM">// add placemark to map</span><span class="WHIT">
<span class='line'>1739</span> </span><span class="WHIT">                </span><span class="NAME">tm.map.addOverlay</span><span class="PUNC">(</span><span class="NAME">placemark</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1740</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1741</span> </span><span class="WHIT">            </span><span class="COMM">// hide placemarks until the next refresh</span><span class="WHIT">
<span class='line'>1742</span> </span><span class="WHIT">            </span><span class="NAME">placemark</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1743</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1744</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1745</span> </span><span class="WHIT">    </span><span class="COMM">// add the item to the dataset</span><span class="WHIT">
<span class='line'>1746</span> </span><span class="WHIT">    </span><span class="NAME">ds.items.push</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1747</span> </span><span class="WHIT">    </span><span class="COMM">// return the item object</span><span class="WHIT">
<span class='line'>1748</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">item</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1749</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1750</span> 
<span class='line'>1751</span> </span><span class="COMM">/*----------------------------------------------------------------------------
<span class='line'>1752</span>  * TimeMapTheme Class
<span class='line'>1753</span>  *---------------------------------------------------------------------------*/</span><span class="WHIT">
<span class='line'>1754</span> 
<span class='line'>1755</span> </span><span class="COMM">/**
<span class='line'>1756</span>  * @class 
<span class='line'>1757</span>  * Predefined visual themes for datasets, defining colors and images for
<span class='line'>1758</span>  * map markers and timeline events. Note that theme is only used at creation
<span class='line'>1759</span>  * time - updating the theme of an existing object won't do anything.
<span class='line'>1760</span>  *
<span class='line'>1761</span>  * @constructor
<span class='line'>1762</span>  * @param {Object} [options]        A container for optional arguments
<span class='line'>1763</span>  * @param {GIcon} [options.icon=G_DEFAULT_ICON]         Icon for marker placemarks.
<span class='line'>1764</span>  * @param {String} [options.iconImage=red-dot.png]      Icon image for marker placemarks 
<span class='line'>1765</span>  *                                                      (assumes G_MARKER_ICON for the rest of the icon settings)
<span class='line'>1766</span>  * @param {String} [options.color=#FE766A]              Default color in hex for events, polylines, polygons.
<span class='line'>1767</span>  * @param {String} [options.lineColor=color]            Color for polylines.
<span class='line'>1768</span>  * @param {String} [options.polygonLineColor=lineColor] Color for polygon outlines.
<span class='line'>1769</span>  * @param {Number} [options.lineOpacity=1]              Opacity for polylines.
<span class='line'>1770</span>  * @param {Number} [options.polgonLineOpacity=lineOpacity]  Opacity for polygon outlines.
<span class='line'>1771</span>  * @param {Number} [options.lineWeight=2]               Line weight in pixels for polylines.
<span class='line'>1772</span>  * @param {Number} [options.polygonLineWeight=lineWeight]   Line weight for polygon outlines.
<span class='line'>1773</span>  * @param {String} [options.fillColor=color]            Color for polygon fill.
<span class='line'>1774</span>  * @param {String} [options.fillOpacity=0.25]           Opacity for polygon fill.
<span class='line'>1775</span>  * @param {String} [options.eventColor=color]           Background color for duration events.
<span class='line'>1776</span>  * @param {String} [options.eventTextColor=null]        Text color for events (null=Timeline default).
<span class='line'>1777</span>  * @param {String} [options.eventIconPath=timemap/images/]  Path to instant event icon directory.
<span class='line'>1778</span>  * @param {String} [options.eventIconImage=red-circle.gif]  Filename of instant event icon image.
<span class='line'>1779</span>  * @param {URL} [options.eventIcon=eventIconPath+eventIconImage] URL for instant event icons.
<span class='line'>1780</span>  * @param {Boolean} [options.classicTape=false]         Whether to use the "classic" style timeline event tape
<span class='line'>1781</span>  *                                                      (needs additional css to work - see examples/artists.html).
<span class='line'>1782</span>  */</span><span class="WHIT">
<span class='line'>1783</span> </span><span class="NAME">TimeMapTheme</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1784</span> 
<span class='line'>1785</span> </span><span class="WHIT">    </span><span class="COMM">// work out various defaults - the default theme is Google's reddish color</span><span class="WHIT">
<span class='line'>1786</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">defaults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1787</span> </span><span class="WHIT">        </span><span class="COMM">/** Default color in hex
<span class='line'>1788</span>          * @name TimeMapTheme#color 
<span class='line'>1789</span>          * @type String */</span><span class="WHIT">
<span class='line'>1790</span> </span><span class="WHIT">        </span><span class="NAME">color</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="STRN">"#FE766A"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1791</span> </span><span class="WHIT">        </span><span class="COMM">/** Opacity for polylines 
<span class='line'>1792</span>          * @name TimeMapTheme#lineOpacity 
<span class='line'>1793</span>          * @type Number */</span><span class="WHIT">
<span class='line'>1794</span> </span><span class="WHIT">        </span><span class="NAME">lineOpacity</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="NUMB">1</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1795</span> </span><span class="WHIT">        </span><span class="COMM">/** Line weight in pixels for polylines
<span class='line'>1796</span>          * @name TimeMapTheme#lineWeight 
<span class='line'>1797</span>          * @type Number */</span><span class="WHIT">
<span class='line'>1798</span> </span><span class="WHIT">        </span><span class="NAME">lineWeight</span><span class="PUNC">:</span><span class="WHIT">     </span><span class="NUMB">2</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1799</span> </span><span class="WHIT">        </span><span class="COMM">/** Opacity for polygon fill 
<span class='line'>1800</span>          * @name TimeMapTheme#fillOpacity 
<span class='line'>1801</span>          * @type Number */</span><span class="WHIT">
<span class='line'>1802</span> </span><span class="WHIT">        </span><span class="NAME">fillOpacity</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="NUMB">0.25</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1803</span> </span><span class="WHIT">        </span><span class="COMM">/** Text color for duration events 
<span class='line'>1804</span>          * @name TimeMapTheme#eventTextColor 
<span class='line'>1805</span>          * @type String */</span><span class="WHIT">
<span class='line'>1806</span> </span><span class="WHIT">        </span><span class="NAME">eventTextColor</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1807</span> </span><span class="WHIT">        </span><span class="COMM">/** Path to instant event icon directory 
<span class='line'>1808</span>          * @name TimeMapTheme#eventIconPath 
<span class='line'>1809</span>          * @type String */</span><span class="WHIT">
<span class='line'>1810</span> </span><span class="WHIT">        </span><span class="NAME">eventIconPath</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="STRN">"timemap/images/"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1811</span> </span><span class="WHIT">        </span><span class="COMM">/** Filename of instant event icon image
<span class='line'>1812</span>          * @name TimeMapTheme#eventIconImage 
<span class='line'>1813</span>          * @type String */</span><span class="WHIT">
<span class='line'>1814</span> </span><span class="WHIT">        </span><span class="NAME">eventIconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"red-circle.png"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1815</span> </span><span class="WHIT">        </span><span class="COMM">/** Whether to use the "classic" style timeline event tape
<span class='line'>1816</span>          * @name TimeMapTheme#classicTape 
<span class='line'>1817</span>          * @type Boolean */</span><span class="WHIT">
<span class='line'>1818</span> </span><span class="WHIT">        </span><span class="NAME">classicTape</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1819</span> </span><span class="WHIT">        </span><span class="COMM">/** Icon image for marker placemarks 
<span class='line'>1820</span>          * @name TimeMapTheme#iconImage 
<span class='line'>1821</span>          * @type String */</span><span class="WHIT">
<span class='line'>1822</span> </span><span class="WHIT">        </span><span class="NAME">iconImage</span><span class="PUNC">:</span><span class="WHIT">      </span><span class="NAME">GIP</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"red-dot.png"</span><span class="WHIT">
<span class='line'>1823</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1824</span> </span><span class="WHIT">    
<span class='line'>1825</span>     </span><span class="COMM">// merge defaults with options</span><span class="WHIT">
<span class='line'>1826</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">settings</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.merge</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">defaults</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1827</span> </span><span class="WHIT">    
<span class='line'>1828</span>     </span><span class="COMM">// kill mergeOnly if necessary</span><span class="WHIT">
<span class='line'>1829</span> </span><span class="WHIT">    </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">settings.mergeOnly</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1830</span> </span><span class="WHIT">    
<span class='line'>1831</span>     </span><span class="COMM">// make default map icon if not supplied</span><span class="WHIT">
<span class='line'>1832</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">settings.icon</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1833</span> </span><span class="WHIT">        </span><span class="COMM">// make new red icon</span><span class="WHIT">
<span class='line'>1834</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">markerIcon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GIcon</span><span class="PUNC">(</span><span class="NAME">G_DEFAULT_ICON</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1835</span> </span><span class="WHIT">        </span><span class="NAME">markerIcon.image</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">settings.iconImage</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1836</span> </span><span class="WHIT">        </span><span class="NAME">markerIcon.iconSize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GSize</span><span class="PUNC">(</span><span class="NUMB">32</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1837</span> </span><span class="WHIT">        </span><span class="NAME">markerIcon.shadow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">GIP</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"msmarker.shadow.png"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1838</span> </span><span class="WHIT">        </span><span class="NAME">markerIcon.shadowSize</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GSize</span><span class="PUNC">(</span><span class="NUMB">59</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1839</span> </span><span class="WHIT">        </span><span class="NAME">markerIcon.iconAnchor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GPoint</span><span class="PUNC">(</span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">33</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1840</span> </span><span class="WHIT">        </span><span class="NAME">markerIcon.infoWindowAnchor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">GPoint</span><span class="PUNC">(</span><span class="NUMB">18</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1841</span> </span><span class="WHIT">        </span><span class="COMM">/** Marker icon for placemarks 
<span class='line'>1842</span>          * @name TimeMapTheme#icon 
<span class='line'>1843</span>          * @type GIcon */</span><span class="WHIT">
<span class='line'>1844</span> </span><span class="WHIT">        </span><span class="NAME">settings.icon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">markerIcon</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1845</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> 
<span class='line'>1846</span>     
<span class='line'>1847</span>     </span><span class="COMM">// cascade some settings as defaults</span><span class="WHIT">
<span class='line'>1848</span> </span><span class="WHIT">    </span><span class="NAME">defaults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1849</span> </span><span class="WHIT">        </span><span class="COMM">/** Line color for polylines
<span class='line'>1850</span>          * @name TimeMapTheme#lineColor 
<span class='line'>1851</span>          * @type String */</span><span class="WHIT">
<span class='line'>1852</span> </span><span class="WHIT">        </span><span class="NAME">lineColor</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NAME">settings.color</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1853</span> </span><span class="WHIT">        </span><span class="COMM">/** Line color for polygons
<span class='line'>1854</span>          * @name TimeMapTheme#polygonLineColor 
<span class='line'>1855</span>          * @type String */</span><span class="WHIT">
<span class='line'>1856</span> </span><span class="WHIT">        </span><span class="NAME">polygonLineColor</span><span class="PUNC">:</span><span class="WHIT">   </span><span class="NAME">settings.color</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1857</span> </span><span class="WHIT">        </span><span class="COMM">/** Opacity for polygon outlines 
<span class='line'>1858</span>          * @name TimeMapTheme#polgonLineOpacity 
<span class='line'>1859</span>          * @type Number */</span><span class="WHIT">
<span class='line'>1860</span> </span><span class="WHIT">        </span><span class="NAME">polgonLineOpacity</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">settings.lineOpacity</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1861</span> </span><span class="WHIT">        </span><span class="COMM">/** Line weight for polygon outlines 
<span class='line'>1862</span>          * @name TimeMapTheme#polygonLineWeight 
<span class='line'>1863</span>          * @type Number */</span><span class="WHIT">
<span class='line'>1864</span> </span><span class="WHIT">        </span><span class="NAME">polygonLineWeight</span><span class="PUNC">:</span><span class="WHIT">  </span><span class="NAME">settings.lineWeight</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1865</span> </span><span class="WHIT">        </span><span class="COMM">/** Fill color for polygons
<span class='line'>1866</span>          * @name TimeMapTheme#fillColor 
<span class='line'>1867</span>          * @type String */</span><span class="WHIT">
<span class='line'>1868</span> </span><span class="WHIT">        </span><span class="NAME">fillColor</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NAME">settings.color</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1869</span> </span><span class="WHIT">        </span><span class="COMM">/** Background color for duration events
<span class='line'>1870</span>          * @name TimeMapTheme#eventColor 
<span class='line'>1871</span>          * @type String */</span><span class="WHIT">
<span class='line'>1872</span> </span><span class="WHIT">        </span><span class="NAME">eventColor</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NAME">settings.color</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1873</span> </span><span class="WHIT">        </span><span class="COMM">/** Full URL for instant event icons
<span class='line'>1874</span>          * @name TimeMapTheme#eventIcon 
<span class='line'>1875</span>          * @type String */</span><span class="WHIT">
<span class='line'>1876</span> </span><span class="WHIT">        </span><span class="NAME">eventIcon</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NAME">settings.eventIconPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">settings.eventIconImage</span><span class="WHIT">
<span class='line'>1877</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1878</span> </span><span class="WHIT">    </span><span class="NAME">settings</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.merge</span><span class="PUNC">(</span><span class="NAME">settings</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">defaults</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1879</span> </span><span class="WHIT">    
<span class='line'>1880</span>     </span><span class="COMM">// return configured options as theme</span><span class="WHIT">
<span class='line'>1881</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">settings</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1882</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1883</span> 
<span class='line'>1884</span> </span><span class="COMM">/**
<span class='line'>1885</span>  * Create a theme, based on an optional new or pre-set theme
<span class='line'>1886</span>  *
<span class='line'>1887</span>  * @param {TimeMapTheme} [theme]    Existing theme to clone
<span class='line'>1888</span>  * @param {Object} [options]        Optional settings to overwrite - see {@link TimeMapTheme}
<span class='line'>1889</span>  * @return {TimeMapTheme}           Configured theme
<span class='line'>1890</span>  */</span><span class="WHIT">
<span class='line'>1891</span> </span><span class="NAME">TimeMapTheme.create</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">theme</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1892</span> </span><span class="WHIT">    </span><span class="COMM">// test for string matches and missing themes</span><span class="WHIT">
<span class='line'>1893</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">theme</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1894</span> </span><span class="WHIT">        </span><span class="NAME">theme</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.util.lookup</span><span class="PUNC">(</span><span class="NAME">theme</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">TimeMap.themes</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1895</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1896</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1897</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1898</span> </span><span class="WHIT">    
<span class='line'>1899</span>     </span><span class="COMM">// see if we need to clone - guessing fewer keys in options</span><span class="WHIT">
<span class='line'>1900</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">clone</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1901</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1902</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">theme.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1903</span> </span><span class="WHIT">            </span><span class="NAME">clone</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1904</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1905</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1906</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1907</span> </span><span class="WHIT">    </span><span class="COMM">// clone if necessary</span><span class="WHIT">
<span class='line'>1908</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">clone</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1909</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">theme</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1910</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">theme.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1911</span> </span><span class="WHIT">                </span><span class="NAME">clone</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">theme</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1912</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1913</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1914</span> </span><span class="WHIT">        </span><span class="COMM">// fix event icon path, allowing full image path in options</span><span class="WHIT">
<span class='line'>1915</span> </span><span class="WHIT">        </span><span class="NAME">clone.eventIcon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options.eventIcon</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> 
<span class='line'>1916</span>             </span><span class="NAME">clone.eventIconPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">clone.eventIconImage</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1917</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">clone</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1918</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1919</span> </span><span class="WHIT">    </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1920</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">theme</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1921</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1922</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1923</span> 
<span class='line'>1924</span> 
<span class='line'>1925</span> </span><span class="COMM">/*----------------------------------------------------------------------------
<span class='line'>1926</span>  * TimeMapItem Class
<span class='line'>1927</span>  *---------------------------------------------------------------------------*/</span><span class="WHIT">
<span class='line'>1928</span> 
<span class='line'>1929</span> </span><span class="COMM">/**
<span class='line'>1930</span>  * @class
<span class='line'>1931</span>  * The TimeMapItem object holds references to one or more map placemarks and 
<span class='line'>1932</span>  * an associated timeline event.
<span class='line'>1933</span>  *
<span class='line'>1934</span>  * @constructor
<span class='line'>1935</span>  * @param {placemark} placemark     Placemark or array of placemarks (GMarker, GPolyline, etc)
<span class='line'>1936</span>  * @param {Event} event             The timeline event
<span class='line'>1937</span>  * @param {TimeMapDataset} dataset  Reference to the parent dataset object
<span class='line'>1938</span>  * @param {Object} [options]        A container for optional arguments
<span class='line'>1939</span>  * @param {String} [options.title=Untitled]         Title of the item
<span class='line'>1940</span>  * @param {String} [options.description]            Plain-text description of the item
<span class='line'>1941</span>  * @param {String} [options.type=none]              Type of map placemark used (marker. polyline, polygon)
<span class='line'>1942</span>  * @param {GLatLng} [options.infoPoint]             Point indicating the center of this item
<span class='line'>1943</span>  * @param {String} [options.infoHtml]               Full HTML for the info window
<span class='line'>1944</span>  * @param {String} [options.infoUrl]                URL from which to retrieve full HTML for the info window
<span class='line'>1945</span>  * @param {String} [options.infoTemplate]           HTML for the info window content, with variable expressions
<span class='line'>1946</span>  *                                                  (as "{{varname}}" by default) to be replaced by option data
<span class='line'>1947</span>  * @param {String} [options.templatePattern=/{{([^}]+)}}/g]
<span class='line'>1948</span>  *                                                  Regex pattern defining variable syntax in the infoTemplate
<span class='line'>1949</span>  * @param {Function} [options.openInfoWindow={@link TimeMapItem.openInfoWindowBasic}]   
<span class='line'>1950</span>  *                                                  Function redefining how info window opens
<span class='line'>1951</span>  * @param {Function} [options.closeInfoWindow={@link TimeMapItem.closeInfoWindowBasic}]  
<span class='line'>1952</span>  *                                                  Function redefining how info window closes
<span class='line'>1953</span>  * @param {String|TimeMapTheme} [options.theme]     Theme applying to this item, overriding dataset theme
<span class='line'>1954</span>  * @param {mixed} [options[...]]                    Any of the options for {@link TimeMapTheme} may be set here
<span class='line'>1955</span>  */</span><span class="WHIT">
<span class='line'>1956</span> </span><span class="NAME">TimeMapItem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">placemark</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dataset</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1957</span> </span><span class="WHIT">    </span><span class="COMM">// improve compression</span><span class="WHIT">
<span class='line'>1958</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1959</span> </span><span class="WHIT">        </span><span class="COMM">// set defaults for options</span><span class="WHIT">
<span class='line'>1960</span> </span><span class="WHIT">        </span><span class="NAME">defaults</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1961</span> </span><span class="WHIT">            </span><span class="NAME">type</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'none'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1962</span> </span><span class="WHIT">            </span><span class="NAME">title</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'Untitled'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1963</span> </span><span class="WHIT">            </span><span class="NAME">description</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1964</span> </span><span class="WHIT">            </span><span class="NAME">infoPoint</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1965</span> </span><span class="WHIT">            </span><span class="NAME">infoHtml</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1966</span> </span><span class="WHIT">            </span><span class="NAME">infoUrl</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1967</span> </span><span class="WHIT">            </span><span class="NAME">infoTemplate</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'&lt;div class="infotitle">{{title}}&lt;/div>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> 
<span class='line'>1968</span>                           </span><span class="STRN">'&lt;div class="infodescription">{{description}}&lt;/div>'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1969</span> </span><span class="WHIT">            </span><span class="NAME">templatePattern</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="REGX">/{{([^}]+)}}/g</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1970</span> </span><span class="WHIT">            </span><span class="NAME">closeInfoWindow</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">TimeMapItem.closeInfoWindowBasic</span><span class="WHIT">
<span class='line'>1971</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1972</span> 
<span class='line'>1973</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>1974</span>      * This item's timeline event
<span class='line'>1975</span>      * @name TimeMapItem#event
<span class='line'>1976</span>      * @type Timeline.Event
<span class='line'>1977</span>      */</span><span class="WHIT">
<span class='line'>1978</span> </span><span class="WHIT">    </span><span class="NAME">item.event</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">event</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1979</span> </span><span class="WHIT">    
<span class='line'>1980</span>     </span><span class="COMM">/**
<span class='line'>1981</span>      * This item's parent dataset
<span class='line'>1982</span>      * @name TimeMapItem#dataset
<span class='line'>1983</span>      * @type TimeMapDataset
<span class='line'>1984</span>      */</span><span class="WHIT">
<span class='line'>1985</span> </span><span class="WHIT">    </span><span class="NAME">item.dataset</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataset</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1986</span> </span><span class="WHIT">    
<span class='line'>1987</span>     </span><span class="COMM">/**
<span class='line'>1988</span>      * The timemap's map object
<span class='line'>1989</span>      * @name TimeMapItem#map
<span class='line'>1990</span>      * @type GMap2
<span class='line'>1991</span>      */</span><span class="WHIT">
<span class='line'>1992</span> </span><span class="WHIT">    </span><span class="NAME">item.map</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataset.timemap.map</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1993</span> </span><span class="WHIT">    
<span class='line'>1994</span>     </span><span class="COMM">/**
<span class='line'>1995</span>      * The timemap's timeline object
<span class='line'>1996</span>      * @name TimeMapItem#timeline
<span class='line'>1997</span>      * @type Timeline
<span class='line'>1998</span>      */</span><span class="WHIT">
<span class='line'>1999</span> </span><span class="WHIT">    </span><span class="NAME">item.timeline</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataset.timemap.timeline</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2000</span> </span><span class="WHIT">    
<span class='line'>2001</span>     </span><span class="COMM">// initialize placemark(s) with some type juggling</span><span class="WHIT">
<span class='line'>2002</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">placemark</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">util.isArray</span><span class="PUNC">(</span><span class="NAME">placemark</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">placemark.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2003</span> </span><span class="WHIT">        </span><span class="NAME">placemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2004</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2005</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">placemark</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">placemark.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2006</span> </span><span class="WHIT">        </span><span class="NAME">placemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">placemark</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2007</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2008</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>2009</span>      * This item's placemark(s)
<span class='line'>2010</span>      * @name TimeMapItem#placemark
<span class='line'>2011</span>      * @type GMarker|GPolyline|GPolygon|GOverlay|Array
<span class='line'>2012</span>      */</span><span class="WHIT">
<span class='line'>2013</span> </span><span class="WHIT">    </span><span class="NAME">item.placemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">placemark</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2014</span> </span><span class="WHIT">    
<span class='line'>2015</span>     </span><span class="COMM">/**
<span class='line'>2016</span>      * Container for optional settings passed in through the "options" parameter
<span class='line'>2017</span>      * @name TimeMapItem#opts
<span class='line'>2018</span>      * @type Object
<span class='line'>2019</span>      */</span><span class="WHIT">
<span class='line'>2020</span> </span><span class="WHIT">    </span><span class="NAME">item.opts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.merge</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">defaults</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dataset.opts</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2021</span> </span><span class="WHIT">    
<span class='line'>2022</span>     </span><span class="COMM">// select default open function</span><span class="WHIT">
<span class='line'>2023</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">options.openInfoWindow</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2024</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">options.infoUrl</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2025</span> </span><span class="WHIT">            </span><span class="COMM">// load via AJAX if URL is provided</span><span class="WHIT">
<span class='line'>2026</span> </span><span class="WHIT">            </span><span class="NAME">options.openInfoWindow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMapItem.openInfoWindowAjax</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2027</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2028</span> </span><span class="WHIT">            </span><span class="COMM">// otherwise default to basic window</span><span class="WHIT">
<span class='line'>2029</span> </span><span class="WHIT">            </span><span class="NAME">options.openInfoWindow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMapItem.openInfoWindowBasic</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2030</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2031</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2032</span> </span><span class="WHIT">    
<span class='line'>2033</span>     </span><span class="COMM">// getter functions</span><span class="WHIT">
<span class='line'>2034</span> </span><span class="WHIT">    
<span class='line'>2035</span>     </span><span class="COMM">/**
<span class='line'>2036</span>      * Return the placemark type for this item
<span class='line'>2037</span>      * @name TimeMapItem#getType
<span class='line'>2038</span>      * @function
<span class='line'>2039</span>      * 
<span class='line'>2040</span>      * @return {String}     Placemark type
<span class='line'>2041</span>      */</span><span class="WHIT">
<span class='line'>2042</span> </span><span class="WHIT">    </span><span class="NAME">item.getType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">item.opts.type</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2043</span> </span><span class="WHIT">    
<span class='line'>2044</span>     </span><span class="COMM">/**
<span class='line'>2045</span>      * Return the title for this item
<span class='line'>2046</span>      * @name TimeMapItem#getTitle
<span class='line'>2047</span>      * @function
<span class='line'>2048</span>      * 
<span class='line'>2049</span>      * @return {String}     Item title
<span class='line'>2050</span>      */</span><span class="WHIT">
<span class='line'>2051</span> </span><span class="WHIT">    </span><span class="NAME">item.getTitle</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">item.opts.title</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2052</span> </span><span class="WHIT">    
<span class='line'>2053</span>     </span><span class="COMM">/**
<span class='line'>2054</span>      * Return the item's "info point" (the anchor for the map info window)
<span class='line'>2055</span>      * @name TimeMapItem#getInfoPoint
<span class='line'>2056</span>      * @function
<span class='line'>2057</span>      * 
<span class='line'>2058</span>      * @return {GLatLng}    Info point
<span class='line'>2059</span>      */</span><span class="WHIT">
<span class='line'>2060</span> </span><span class="WHIT">    </span><span class="NAME">item.getInfoPoint</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> 
<span class='line'>2061</span>         </span><span class="COMM">// default to map center if placemark not set</span><span class="WHIT">
<span class='line'>2062</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">item.opts.infoPoint</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">item.map.getCenter</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> 
<span class='line'>2063</span>     </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2064</span> </span><span class="WHIT">    
<span class='line'>2065</span>     </span><span class="COMM">/**
<span class='line'>2066</span>      * Return the start date of the item's event, if any
<span class='line'>2067</span>      * @name TimeMapItem#getStart
<span class='line'>2068</span>      * @function
<span class='line'>2069</span>      * 
<span class='line'>2070</span>      * @return {Date}   Item start date or undefined
<span class='line'>2071</span>      */</span><span class="WHIT">
<span class='line'>2072</span> </span><span class="WHIT">    </span><span class="NAME">item.getStart</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2073</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item.event</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2074</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">item.event.getStart</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2075</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2076</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2077</span> </span><span class="WHIT">    
<span class='line'>2078</span>     </span><span class="COMM">/**
<span class='line'>2079</span>      * Return the end date of the item's event, if any
<span class='line'>2080</span>      * @name TimeMapItem#getEnd
<span class='line'>2081</span>      * @function
<span class='line'>2082</span>      * 
<span class='line'>2083</span>      * @return {Date}   Item end dateor undefined
<span class='line'>2084</span>      */</span><span class="WHIT">
<span class='line'>2085</span> </span><span class="WHIT">    </span><span class="NAME">item.getEnd</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2086</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item.event</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2087</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">item.event.getEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2088</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2089</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2090</span> </span><span class="WHIT">    
<span class='line'>2091</span>     </span><span class="COMM">/**
<span class='line'>2092</span>      * Return the timestamp of the start date of the item's event, if any
<span class='line'>2093</span>      * @name TimeMapItem#getStartTime
<span class='line'>2094</span>      * @function
<span class='line'>2095</span>      * 
<span class='line'>2096</span>      * @return {Number}    Item start date timestamp or undefined
<span class='line'>2097</span>      */</span><span class="WHIT">
<span class='line'>2098</span> </span><span class="WHIT">    </span><span class="NAME">item.getStartTime</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2099</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item.getStart</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2100</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">start</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2101</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">start.getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2102</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2103</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2104</span> </span><span class="WHIT">    
<span class='line'>2105</span>     </span><span class="COMM">/**
<span class='line'>2106</span>      * Return the timestamp of the end date of the item's event, if any
<span class='line'>2107</span>      * @name TimeMapItem#getEndTime
<span class='line'>2108</span>      * @function
<span class='line'>2109</span>      * 
<span class='line'>2110</span>      * @return {Number}    Item end date timestamp or undefined
<span class='line'>2111</span>      */</span><span class="WHIT">
<span class='line'>2112</span> </span><span class="WHIT">    </span><span class="NAME">item.getEndTime</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2113</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">end</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item.getEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2114</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">end</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2115</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">end.getTime</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2116</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2117</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2118</span> </span><span class="WHIT">    
<span class='line'>2119</span>     </span><span class="COMM">/**
<span class='line'>2120</span>      * Whether the item is currently selected
<span class='line'>2121</span>      * @name TimeMapItem#selected
<span class='line'>2122</span>      * @type Boolean
<span class='line'>2123</span>      */</span><span class="WHIT">
<span class='line'>2124</span> </span><span class="WHIT">    </span><span class="NAME">item.selected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2125</span> </span><span class="WHIT">    
<span class='line'>2126</span>     </span><span class="COMM">/**
<span class='line'>2127</span>      * Whether the item is visible
<span class='line'>2128</span>      * @name TimeMapItem#visible
<span class='line'>2129</span>      * @type Boolean
<span class='line'>2130</span>      */</span><span class="WHIT">
<span class='line'>2131</span> </span><span class="WHIT">    </span><span class="NAME">item.visible</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2132</span> </span><span class="WHIT">    
<span class='line'>2133</span>     </span><span class="COMM">/**
<span class='line'>2134</span>      * Whether the item's placemark is visible
<span class='line'>2135</span>      * @name TimeMapItem#placemarkVisible
<span class='line'>2136</span>      * @type Boolean
<span class='line'>2137</span>      */</span><span class="WHIT">
<span class='line'>2138</span> </span><span class="WHIT">    </span><span class="NAME">item.placemarkVisible</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2139</span> </span><span class="WHIT">    
<span class='line'>2140</span>     </span><span class="COMM">/**
<span class='line'>2141</span>      * Whether the item's event is visible
<span class='line'>2142</span>      * @name TimeMapItem#eventVisible
<span class='line'>2143</span>      * @type Boolean
<span class='line'>2144</span>      */</span><span class="WHIT">
<span class='line'>2145</span> </span><span class="WHIT">    </span><span class="NAME">item.eventVisible</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2146</span> </span><span class="WHIT">    
<span class='line'>2147</span>     </span><span class="COMM">/**
<span class='line'>2148</span>      * Open the info window for this item.
<span class='line'>2149</span>      * By default this is the map infoWindow, but you can set custom functions
<span class='line'>2150</span>      * for whatever behavior you want when the event or placemark is clicked
<span class='line'>2151</span>      * @name TimeMapItem#openInfoWindow
<span class='line'>2152</span>      * @function
<span class='line'>2153</span>      */</span><span class="WHIT">
<span class='line'>2154</span> </span><span class="WHIT">    </span><span class="NAME">item.openInfoWindow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2155</span> </span><span class="WHIT">        </span><span class="NAME">options.openInfoWindow.call</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2156</span> </span><span class="WHIT">        </span><span class="NAME">item.selected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2157</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2158</span> </span><span class="WHIT">    
<span class='line'>2159</span>     </span><span class="COMM">/**
<span class='line'>2160</span>      * Close the info window for this item.
<span class='line'>2161</span>      * By default this is the map infoWindow, but you can set custom functions
<span class='line'>2162</span>      * for whatever behavior you want.
<span class='line'>2163</span>      * @name TimeMapItem#closeInfoWindow
<span class='line'>2164</span>      * @function
<span class='line'>2165</span>      */</span><span class="WHIT">
<span class='line'>2166</span> </span><span class="WHIT">    </span><span class="NAME">item.closeInfoWindow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2167</span> </span><span class="WHIT">        </span><span class="NAME">options.closeInfoWindow.call</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2168</span> </span><span class="WHIT">        </span><span class="NAME">item.selected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2169</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2170</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2171</span> 
<span class='line'>2172</span> </span><span class="COMM">/** 
<span class='line'>2173</span>  * Show the map placemark(s)
<span class='line'>2174</span>  */</span><span class="WHIT">
<span class='line'>2175</span> </span><span class="NAME">TimeMapItem.prototype.showPlacemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2176</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2177</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item.placemark</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2178</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item.getType</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"array"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2179</span> </span><span class="WHIT">            </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">item.placemark.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2180</span> </span><span class="WHIT">                </span><span class="NAME">item.placemark</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">show</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2181</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2182</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2183</span> </span><span class="WHIT">            </span><span class="NAME">item.placemark.show</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2184</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2185</span> </span><span class="WHIT">        </span><span class="NAME">item.placemarkVisible</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2186</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2187</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2188</span> 
<span class='line'>2189</span> </span><span class="COMM">/** 
<span class='line'>2190</span>  * Hide the map placemark(s)
<span class='line'>2191</span>  */</span><span class="WHIT">
<span class='line'>2192</span> </span><span class="NAME">TimeMapItem.prototype.hidePlacemark</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2193</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2194</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item.placemark</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2195</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item.getType</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"array"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2196</span> </span><span class="WHIT">            </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">item.placemark.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2197</span> </span><span class="WHIT">                </span><span class="NAME">item.placemark</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2198</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2199</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2200</span> </span><span class="WHIT">            </span><span class="NAME">item.placemark.hide</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2201</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2202</span> </span><span class="WHIT">        </span><span class="NAME">item.placemarkVisible</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2203</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2204</span> </span><span class="WHIT">    </span><span class="NAME">item.closeInfoWindow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2205</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2206</span> 
<span class='line'>2207</span> </span><span class="COMM">/** 
<span class='line'>2208</span>  * Show the timeline event.
<span class='line'>2209</span>  * NB: Will likely require calling timeline.layout()
<span class='line'>2210</span>  */</span><span class="WHIT">
<span class='line'>2211</span> </span><span class="NAME">TimeMapItem.prototype.showEvent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2212</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.event</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2213</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.eventVisible</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2214</span> </span><span class="WHIT">            </span><span class="NAME">this.dataset.timemap.timeline.getBand</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2215</span> </span><span class="WHIT">                </span><span class="PUNC">.</span><span class="NAME">getEventSource</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">_events._events.add</span><span class="PUNC">(</span><span class="NAME">this.event</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2216</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2217</span> </span><span class="WHIT">        </span><span class="NAME">this.eventVisible</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2218</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2219</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2220</span> 
<span class='line'>2221</span> </span><span class="COMM">/** 
<span class='line'>2222</span>  * Hide the timeline event.
<span class='line'>2223</span>  * NB: Will likely require calling timeline.layout(),
<span class='line'>2224</span>  * AND calling eventSource._events._index()  (ugh)
<span class='line'>2225</span>  */</span><span class="WHIT">
<span class='line'>2226</span> </span><span class="NAME">TimeMapItem.prototype.hideEvent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2227</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.event</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2228</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.eventVisible</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2229</span> </span><span class="WHIT">            </span><span class="NAME">this.dataset.timemap.timeline.getBand</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2230</span> </span><span class="WHIT">                </span><span class="PUNC">.</span><span class="NAME">getEventSource</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">_events._events.remove</span><span class="PUNC">(</span><span class="NAME">this.event</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2231</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2232</span> </span><span class="WHIT">        </span><span class="NAME">this.eventVisible</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2233</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2234</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> 
<span class='line'>2235</span> 
<span class='line'>2236</span> </span><span class="COMM">/**
<span class='line'>2237</span>  * Standard open info window function, using static text in map window
<span class='line'>2238</span>  */</span><span class="WHIT">
<span class='line'>2239</span> </span><span class="NAME">TimeMapItem.openInfoWindowBasic</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2240</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2241</span> </span><span class="WHIT">        </span><span class="NAME">opts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">item.opts</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2242</span> </span><span class="WHIT">        </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opts.infoHtml</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2243</span> </span><span class="WHIT">        </span><span class="NAME">match</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2244</span> </span><span class="WHIT">    </span><span class="COMM">// create content for info window if none is provided</span><span class="WHIT">
<span class='line'>2245</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">html</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2246</span> </span><span class="WHIT">        </span><span class="COMM">// fill in template</span><span class="WHIT">
<span class='line'>2247</span> </span><span class="WHIT">        </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opts.infoTemplate</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2248</span> </span><span class="WHIT">        </span><span class="NAME">match</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opts.templatePattern.exec</span><span class="PUNC">(</span><span class="NAME">html</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2249</span> </span><span class="WHIT">        </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">match</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2250</span> </span><span class="WHIT">            </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">html.replace</span><span class="PUNC">(</span><span class="NAME">match</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opts</span><span class="PUNC">[</span><span class="NAME">match</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2251</span> </span><span class="WHIT">            </span><span class="NAME">match</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opts.templatePattern.exec</span><span class="PUNC">(</span><span class="NAME">html</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2252</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2253</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2254</span> </span><span class="WHIT">    </span><span class="COMM">// scroll timeline if necessary</span><span class="WHIT">
<span class='line'>2255</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item.placemark</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">item.placemarkVisible</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">item.event</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2256</span> </span><span class="WHIT">        </span><span class="NAME">item.dataset.timemap.scrollToDate</span><span class="PUNC">(</span><span class="NAME">item.event.getStart</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2257</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2258</span> </span><span class="WHIT">    </span><span class="COMM">// open window</span><span class="WHIT">
<span class='line'>2259</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item.getType</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"marker"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2260</span> </span><span class="WHIT">        </span><span class="NAME">item.placemark.openInfoWindowHtml</span><span class="PUNC">(</span><span class="NAME">html</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2261</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2262</span> </span><span class="WHIT">        </span><span class="NAME">item.map.openInfoWindowHtml</span><span class="PUNC">(</span><span class="NAME">item.getInfoPoint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">html</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2263</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2264</span> </span><span class="WHIT">    </span><span class="COMM">// deselect when window is closed</span><span class="WHIT">
<span class='line'>2265</span> </span><span class="WHIT">    </span><span class="NAME">item.closeListener</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">GEvent.addListener</span><span class="PUNC">(</span><span class="NAME">item.map</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"infowindowclose"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> 
<span class='line'>2266</span>         </span><span class="COMM">// deselect</span><span class="WHIT">
<span class='line'>2267</span> </span><span class="WHIT">        </span><span class="NAME">item.selected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2268</span> </span><span class="WHIT">        </span><span class="COMM">// kill self</span><span class="WHIT">
<span class='line'>2269</span> </span><span class="WHIT">        </span><span class="NAME">GEvent.removeListener</span><span class="PUNC">(</span><span class="NAME">item.closeListener</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2270</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2271</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2272</span> 
<span class='line'>2273</span> </span><span class="COMM">/**
<span class='line'>2274</span>  * Open info window function using ajax-loaded text in map window
<span class='line'>2275</span>  */</span><span class="WHIT">
<span class='line'>2276</span> </span><span class="NAME">TimeMapItem.openInfoWindowAjax</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2277</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">item</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2278</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">item.opts.infoHtml</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// load content via AJAX</span><span class="WHIT">
<span class='line'>2279</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">item.opts.infoUrl</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2280</span> </span><span class="WHIT">            </span><span class="NAME">GDownloadUrl</span><span class="PUNC">(</span><span class="NAME">item.opts.infoUrl</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">result</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2281</span> </span><span class="WHIT">                    </span><span class="NAME">item.opts.infoHtml</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2282</span> </span><span class="WHIT">                    </span><span class="NAME">item.openInfoWindow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2283</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2284</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2285</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2286</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2287</span> </span><span class="WHIT">    </span><span class="COMM">// fall back on basic function if content is loaded or URL is missing</span><span class="WHIT">
<span class='line'>2288</span> </span><span class="WHIT">    </span><span class="NAME">item.openInfoWindow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2289</span> </span><span class="WHIT">        </span><span class="NAME">TimeMapItem.openInfoWindowBasic.call</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2290</span> </span><span class="WHIT">        </span><span class="NAME">item.selected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2291</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2292</span> </span><span class="WHIT">    </span><span class="NAME">item.openInfoWindow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2293</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2294</span> 
<span class='line'>2295</span> </span><span class="COMM">/**
<span class='line'>2296</span>  * Standard close window function, using the map window
<span class='line'>2297</span>  */</span><span class="WHIT">
<span class='line'>2298</span> </span><span class="NAME">TimeMapItem.closeInfoWindowBasic</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2299</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.getType</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"marker"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2300</span> </span><span class="WHIT">        </span><span class="NAME">this.placemark.closeInfoWindow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2301</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2302</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">infoWindow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.map.getInfoWindow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2303</span> </span><span class="WHIT">        </span><span class="COMM">// close info window if its point is the same as this item's point</span><span class="WHIT">
<span class='line'>2304</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">infoWindow.getPoint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">this.getInfoPoint</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">infoWindow.isHidden</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2305</span> </span><span class="WHIT">            </span><span class="NAME">this.map.closeInfoWindow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2306</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2307</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2308</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2309</span> 
<span class='line'>2310</span> </span><span class="COMM">/*----------------------------------------------------------------------------
<span class='line'>2311</span>  * Utility functions
<span class='line'>2312</span>  *---------------------------------------------------------------------------*/</span><span class="WHIT">
<span class='line'>2313</span> 
<span class='line'>2314</span> </span><span class="COMM">/**
<span class='line'>2315</span>  * Convenience trim function
<span class='line'>2316</span>  * 
<span class='line'>2317</span>  * @param {String} str      String to trim
<span class='line'>2318</span>  * @return {String}         Trimmed string
<span class='line'>2319</span>  */</span><span class="WHIT">
<span class='line'>2320</span> </span><span class="NAME">TimeMap.util.trim</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2321</span> </span><span class="WHIT">    </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">str</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2322</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">str.replace</span><span class="PUNC">(</span><span class="REGX">/^\s\s*/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">replace</span><span class="PUNC">(</span><span class="REGX">/\s\s*$/</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2323</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2324</span> 
<span class='line'>2325</span> </span><span class="COMM">/**
<span class='line'>2326</span>  * Convenience array tester
<span class='line'>2327</span>  *
<span class='line'>2328</span>  * @param {Object} o        Object to test
<span class='line'>2329</span>  * @return {Boolean}        Whether the object is an array
<span class='line'>2330</span>  */</span><span class="WHIT">
<span class='line'>2331</span> </span><span class="NAME">TimeMap.util.isArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">   
<span class='line'>2332</span>     </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">o.propertyIsEnumerable</span><span class="PUNC">(</span><span class="STRN">'length'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> 
<span class='line'>2333</span>         </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">o.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2334</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2335</span> 
<span class='line'>2336</span> </span><span class="COMM">/**
<span class='line'>2337</span>  * Get XML tag value as a string
<span class='line'>2338</span>  *
<span class='line'>2339</span>  * @param {XML Node} n      Node in which to look for tag
<span class='line'>2340</span>  * @param {String} tag      Name of tag to look for
<span class='line'>2341</span>  * @param {String} [ns]     XML namespace to look in
<span class='line'>2342</span>  * @return {String}         Tag value as string
<span class='line'>2343</span>  */</span><span class="WHIT">
<span class='line'>2344</span> </span><span class="NAME">TimeMap.util.getTagValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tag</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ns</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2345</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2346</span> </span><span class="WHIT">        </span><span class="NAME">nList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.util.getNodeList</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tag</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ns</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2347</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">nList.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2348</span> </span><span class="WHIT">        </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">nList</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">firstChild</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2349</span> </span><span class="WHIT">        </span><span class="COMM">// fix for extra-long nodes</span><span class="WHIT">
<span class='line'>2350</span> </span><span class="WHIT">        </span><span class="COMM">// see http://code.google.com/p/timemap/issues/detail?id=36</span><span class="WHIT">
<span class='line'>2351</span> </span><span class="WHIT">        </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2352</span> </span><span class="WHIT">            </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.nodeValue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2353</span> </span><span class="WHIT">            </span><span class="NAME">n</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">n.nextSibling</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2354</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2355</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2356</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2357</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2358</span> 
<span class='line'>2359</span> </span><span class="COMM">/**
<span class='line'>2360</span>  * Empty container for mapping XML namespaces to URLs
<span class='line'>2361</span>  * @example
<span class='line'>2362</span>  TimeMap.util.nsMap['georss'] = 'http://www.georss.org/georss';
<span class='line'>2363</span>  // find georss:point
<span class='line'>2364</span>  TimeMap.util.getNodeList(node, 'point', 'georss')
<span class='line'>2365</span>  */</span><span class="WHIT">
<span class='line'>2366</span> </span><span class="NAME">TimeMap.util.nsMap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2367</span> 
<span class='line'>2368</span> </span><span class="COMM">/**
<span class='line'>2369</span>  * Cross-browser implementation of getElementsByTagNameNS.
<span class='line'>2370</span>  * Note: Expects any applicable namespaces to be mapped in
<span class='line'>2371</span>  * {@link TimeMap.util.nsMap}.
<span class='line'>2372</span>  *
<span class='line'>2373</span>  * @param {XML Node} n      Node in which to look for tag
<span class='line'>2374</span>  * @param {String} tag      Name of tag to look for
<span class='line'>2375</span>  * @param {String} [ns]     XML namespace to look in
<span class='line'>2376</span>  * @return {XML Node List}  List of nodes with the specified tag name
<span class='line'>2377</span>  */</span><span class="WHIT">
<span class='line'>2378</span> </span><span class="NAME">TimeMap.util.getNodeList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">n</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tag</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ns</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2379</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">nsMap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.util.nsMap</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2380</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ns</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2381</span> </span><span class="WHIT">        </span><span class="COMM">// no namespace</span><span class="WHIT">
<span class='line'>2382</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.getElementsByTagName</span><span class="PUNC">(</span><span class="NAME">tag</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2383</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2384</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">n.getElementsByTagNameNS</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">nsMap</span><span class="PUNC">[</span><span class="NAME">ns</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2385</span> </span><span class="WHIT">        </span><span class="COMM">// function and namespace both exist</span><span class="WHIT">
<span class='line'>2386</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.getElementsByTagNameNS</span><span class="PUNC">(</span><span class="NAME">nsMap</span><span class="PUNC">[</span><span class="NAME">ns</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tag</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2387</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2388</span> </span><span class="WHIT">    </span><span class="COMM">// no function, try the colon tag name</span><span class="WHIT">
<span class='line'>2389</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">n.getElementsByTagName</span><span class="PUNC">(</span><span class="NAME">ns</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">':'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">tag</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2390</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2391</span> 
<span class='line'>2392</span> </span><span class="COMM">/**
<span class='line'>2393</span>  * Make TimeMap.init()-style points from a GLatLng, array, or string
<span class='line'>2394</span>  *
<span class='line'>2395</span>  * @param {Object} coords       GLatLng, array, or string to convert
<span class='line'>2396</span>  * @param {Boolean} [reversed]  Whether the points are KML-style lon/lat, rather than lat/lon
<span class='line'>2397</span>  * @return {Object}             TimeMap.init()-style point 
<span class='line'>2398</span>  */</span><span class="WHIT">
<span class='line'>2399</span> </span><span class="NAME">TimeMap.util.makePoint</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reversed</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2400</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">latlon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>2401</span>         </span><span class="NAME">trim</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.util.trim</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2402</span> </span><span class="WHIT">    </span><span class="COMM">// GLatLng</span><span class="WHIT">
<span class='line'>2403</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">coords.lat</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">coords.lng</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2404</span> </span><span class="WHIT">        </span><span class="NAME">latlon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">coords.lat</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">coords.lng</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2405</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2406</span> </span><span class="WHIT">    </span><span class="COMM">// array of coordinates</span><span class="WHIT">
<span class='line'>2407</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">TimeMap.util.isArray</span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2408</span> </span><span class="WHIT">        </span><span class="NAME">latlon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">coords</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2409</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2410</span> </span><span class="WHIT">    </span><span class="COMM">// string</span><span class="WHIT">
<span class='line'>2411</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">latlon</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2412</span> </span><span class="WHIT">        </span><span class="COMM">// trim extra whitespace</span><span class="WHIT">
<span class='line'>2413</span> </span><span class="WHIT">        </span><span class="NAME">coords</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">trim</span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2414</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">coords.indexOf</span><span class="PUNC">(</span><span class="STRN">','</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2415</span> </span><span class="WHIT">            </span><span class="COMM">// split on commas</span><span class="WHIT">
<span class='line'>2416</span> </span><span class="WHIT">            </span><span class="NAME">latlon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">coords.split</span><span class="PUNC">(</span><span class="STRN">","</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2417</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2418</span> </span><span class="WHIT">            </span><span class="COMM">// split on whitespace</span><span class="WHIT">
<span class='line'>2419</span> </span><span class="WHIT">            </span><span class="NAME">latlon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">coords.split</span><span class="PUNC">(</span><span class="REGX">/[\r\n\f ]+/</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2420</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2421</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2422</span> </span><span class="WHIT">    </span><span class="COMM">// deal with extra coordinates (i.e. KML altitude)</span><span class="WHIT">
<span class='line'>2423</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">latlon.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2424</span> </span><span class="WHIT">        </span><span class="NAME">latlon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">latlon.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2425</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2426</span> </span><span class="WHIT">    </span><span class="COMM">// deal with backwards (i.e. KML-style) coordinates</span><span class="WHIT">
<span class='line'>2427</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">reversed</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2428</span> </span><span class="WHIT">        </span><span class="NAME">latlon.reverse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2429</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2430</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2431</span> </span><span class="WHIT">        </span><span class="STRN">"lat"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">trim</span><span class="PUNC">(</span><span class="NAME">latlon</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2432</span> </span><span class="WHIT">        </span><span class="STRN">"lon"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">trim</span><span class="PUNC">(</span><span class="NAME">latlon</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2433</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2434</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2435</span> 
<span class='line'>2436</span> </span><span class="COMM">/**
<span class='line'>2437</span>  * Make TimeMap.init()-style polyline/polygons from a whitespace-delimited
<span class='line'>2438</span>  * string of coordinates (such as those in GeoRSS and KML).
<span class='line'>2439</span>  *
<span class='line'>2440</span>  * @param {Object} coords       String to convert
<span class='line'>2441</span>  * @param {Boolean} [reversed]  Whether the points are KML-style lon/lat, rather than lat/lon
<span class='line'>2442</span>  * @return {Object}             Formated coordinate array
<span class='line'>2443</span>  */</span><span class="WHIT">
<span class='line'>2444</span> </span><span class="NAME">TimeMap.util.makePoly</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reversed</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2445</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">poly</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>2446</span>         </span><span class="NAME">latlon</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2447</span> </span><span class="WHIT">        </span><span class="NAME">coordArr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.util.trim</span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="REGX">/[\r\n\f ]+/</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2448</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">coordArr.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2449</span> </span><span class="WHIT">    </span><span class="COMM">// loop through coordinates</span><span class="WHIT">
<span class='line'>2450</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">&lt;</span><span class="NAME">coordArr.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2451</span> </span><span class="WHIT">        </span><span class="NAME">latlon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">coordArr</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">indexOf</span><span class="PUNC">(</span><span class="STRN">','</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT">
<span class='line'>2452</span> </span><span class="WHIT">            </span><span class="COMM">// comma-separated coordinates (KML-style lon/lat)</span><span class="WHIT">
<span class='line'>2453</span> </span><span class="WHIT">            </span><span class="NAME">coordArr</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="STRN">","</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2454</span> </span><span class="WHIT">            </span><span class="COMM">// space-separated coordinates - increment to step by 2s</span><span class="WHIT">
<span class='line'>2455</span> </span><span class="WHIT">            </span><span class="PUNC">[</span><span class="NAME">coordArr</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">coordArr</span><span class="PUNC">[</span><span class="PUNC">++</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2456</span> </span><span class="WHIT">        </span><span class="COMM">// deal with extra coordinates (i.e. KML altitude)</span><span class="WHIT">
<span class='line'>2457</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">latlon.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2458</span> </span><span class="WHIT">            </span><span class="NAME">latlon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">latlon.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2459</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2460</span> </span><span class="WHIT">        </span><span class="COMM">// deal with backwards (i.e. KML-style) coordinates</span><span class="WHIT">
<span class='line'>2461</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">reversed</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2462</span> </span><span class="WHIT">            </span><span class="NAME">latlon.reverse</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2463</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2464</span> </span><span class="WHIT">        </span><span class="NAME">poly.push</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2465</span> </span><span class="WHIT">            </span><span class="STRN">"lat"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">latlon</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2466</span> </span><span class="WHIT">            </span><span class="STRN">"lon"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">latlon</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>2467</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2468</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2469</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">poly</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2470</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2471</span> 
<span class='line'>2472</span> </span><span class="COMM">/**
<span class='line'>2473</span>  * Format a date as an ISO 8601 string
<span class='line'>2474</span>  *
<span class='line'>2475</span>  * @param {Date} d          Date to format
<span class='line'>2476</span>  * @param {Number} [precision] Precision indicator:&lt;pre>
<span class='line'>2477</span>  *      3 (default): Show full date and time
<span class='line'>2478</span>  *      2: Show full date and time, omitting seconds
<span class='line'>2479</span>  *      1: Show date only
<span class='line'>2480</span>  *&lt;/pre>
<span class='line'>2481</span>  * @return {String}         Formatted string
<span class='line'>2482</span>  */</span><span class="WHIT">
<span class='line'>2483</span> </span><span class="NAME">TimeMap.util.formatDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">precision</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2484</span> </span><span class="WHIT">    </span><span class="COMM">// default to high precision</span><span class="WHIT">
<span class='line'>2485</span> </span><span class="WHIT">    </span><span class="NAME">precision</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">precision</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2486</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2487</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2488</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">yyyy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getUTCFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2489</span> </span><span class="WHIT">            </span><span class="NAME">mo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getUTCMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2490</span> </span><span class="WHIT">            </span><span class="NAME">dd</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getUTCDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2491</span> </span><span class="WHIT">        </span><span class="COMM">// deal with early dates</span><span class="WHIT">
<span class='line'>2492</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">yyyy</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">1000</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2493</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">yyyy</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">yyyy</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"BC"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">yyyy</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2494</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2495</span> </span><span class="WHIT">        </span><span class="COMM">// check for date.js support</span><span class="WHIT">
<span class='line'>2496</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d.toISOString</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">precision</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2497</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d.toISOString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2498</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2499</span> </span><span class="WHIT">        </span><span class="COMM">// otherwise, build ISO 8601 string</span><span class="WHIT">
<span class='line'>2500</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">num</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2501</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">num</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">10</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"0"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">num</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2502</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2503</span> </span><span class="WHIT">        </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">yyyy</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">mo</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'-'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">dd</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2504</span> </span><span class="WHIT">        </span><span class="COMM">// show time if top interval less than a week</span><span class="WHIT">
<span class='line'>2505</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">precision</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2506</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hh</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getUTCHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2507</span> </span><span class="WHIT">                </span><span class="NAME">mm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getUTCMinutes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2508</span> </span><span class="WHIT">                </span><span class="NAME">ss</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">d.getUTCSeconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2509</span> </span><span class="WHIT">            </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'T'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">hh</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">':'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">mm</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2510</span> </span><span class="WHIT">            </span><span class="COMM">// show seconds if the interval is less than a day</span><span class="WHIT">
<span class='line'>2511</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">precision</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2512</span> </span><span class="WHIT">                </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pad</span><span class="PUNC">(</span><span class="NAME">ss</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2513</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2514</span> </span><span class="WHIT">            </span><span class="NAME">str</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'Z'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2515</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2516</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2517</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">str</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2518</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2519</span> 
<span class='line'>2520</span> </span><span class="COMM">/**
<span class='line'>2521</span>  * Determine the SIMILE Timeline version.
<span class='line'>2522</span>  *
<span class='line'>2523</span>  * @return {String}     At the moment, only "1.2", "2.2.0", or what Timeline provides
<span class='line'>2524</span>  */</span><span class="WHIT">
<span class='line'>2525</span> </span><span class="NAME">TimeMap.util.TimelineVersion</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2526</span> </span><span class="WHIT">    </span><span class="COMM">// check for Timeline.version support - added in 2.3.0</span><span class="WHIT">
<span class='line'>2527</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Timeline.version</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2528</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Timeline.version</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2529</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2530</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Timeline.DurationEventPainter</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2531</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"1.2"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2532</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2533</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">"2.2.0"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2534</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2535</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2536</span> 
<span class='line'>2537</span> 
<span class='line'>2538</span> </span><span class="COMM">/** 
<span class='line'>2539</span>  * Identify the placemark type. 
<span class='line'>2540</span>  * XXX: Not 100% happy with this implementation, which relies heavily on duck-typing.
<span class='line'>2541</span>  *
<span class='line'>2542</span>  * @param {Object} pm       Placemark to identify
<span class='line'>2543</span>  * @return {String}         Type of placemark, or false if none found
<span class='line'>2544</span>  */</span><span class="WHIT">
<span class='line'>2545</span> </span><span class="NAME">TimeMap.util.getPlacemarkType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2546</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="STRN">'getIcon'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">pm</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'marker'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2547</span> </span><span class="WHIT">        </span><span class="STRN">'getVertex'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">pm</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> 
<span class='line'>2548</span>             </span><span class="PUNC">(</span><span class="STRN">'setFillStyle'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">pm</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'polygon'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'polyline'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>2549</span> </span><span class="WHIT">        </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2550</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2551</span> 
<span class='line'>2552</span> </span><span class="COMM">/**
<span class='line'>2553</span>  * Merge two or more objects, giving precendence to those
<span class='line'>2554</span>  * first in the list (i.e. don't overwrite existing keys).
<span class='line'>2555</span>  * Original objects will not be modified.
<span class='line'>2556</span>  *
<span class='line'>2557</span>  * @param {Object} obj1     Base object
<span class='line'>2558</span>  * @param {Object} [objN]   Objects to merge into base
<span class='line'>2559</span>  * @return {Object}         Merged object
<span class='line'>2560</span>  */</span><span class="WHIT">
<span class='line'>2561</span> </span><span class="NAME">TimeMap.util.merge</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2562</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">opts</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">args</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2563</span> </span><span class="WHIT">    </span><span class="COMM">// must... make... subroutine...</span><span class="WHIT">
<span class='line'>2564</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">mergeKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">o1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">o2</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2565</span> </span><span class="WHIT">        </span><span class="COMM">// note: existing keys w/undefined values will be overwritten</span><span class="WHIT">
<span class='line'>2566</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">o1.hasOwnProperty</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">o2</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2567</span> </span><span class="WHIT">            </span><span class="NAME">o2</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o1</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2568</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2569</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2570</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">&lt;</span><span class="NAME">args.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2571</span> </span><span class="WHIT">        </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">args</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2572</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2573</span> </span><span class="WHIT">            </span><span class="COMM">// allow non-base objects to constrain what will be merged</span><span class="WHIT">
<span class='line'>2574</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="STRN">'mergeOnly'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2575</span> </span><span class="WHIT">                </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">y</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">&lt;</span><span class="NAME">obj.mergeOnly.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">y</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2576</span> </span><span class="WHIT">                    </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj.mergeOnly</span><span class="PUNC">[</span><span class="NAME">y</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2577</span> </span><span class="WHIT">                    </span><span class="NAME">mergeKey</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opts</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2578</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2579</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2580</span> </span><span class="WHIT">            </span><span class="COMM">// otherwise, just merge everything</span><span class="WHIT">
<span class='line'>2581</span> </span><span class="WHIT">            </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2582</span> </span><span class="WHIT">                </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2583</span> </span><span class="WHIT">                    </span><span class="NAME">mergeKey</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opts</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2584</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2585</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2586</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2587</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2588</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opts</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2589</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2590</span> 
<span class='line'>2591</span> </span><span class="COMM">/**
<span class='line'>2592</span>  * Attempt look up a key in an object, returning either the value,
<span class='line'>2593</span>  * undefined if the key is a string but not found, or the key if not a string 
<span class='line'>2594</span>  *
<span class='line'>2595</span>  * @param {String|Object} key   Key to look up
<span class='line'>2596</span>  * @param {Object} map          Object in which to look
<span class='line'>2597</span>  * @return {Object}             Value, undefined, or key
<span class='line'>2598</span>  */</span><span class="WHIT">
<span class='line'>2599</span> </span><span class="NAME">TimeMap.util.lookup</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">map</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2600</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2601</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">map</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2602</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2603</span> </span><span class="WHIT">    </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2604</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2605</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>2606</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2607</span> 
<span class='line'>2608</span> 
<span class='line'>2609</span> </span><span class="COMM">/*----------------------------------------------------------------------------
<span class='line'>2610</span>  * Lookup maps
<span class='line'>2611</span>  * (need to be at end because some call util functions on initialization)
<span class='line'>2612</span>  *---------------------------------------------------------------------------*/</span><span class="WHIT">
<span class='line'>2613</span> 
<span class='line'>2614</span> </span><span class="COMM">/**
<span class='line'>2615</span>  * @namespace
<span class='line'>2616</span>  * Lookup map of common timeline intervals.  
<span class='line'>2617</span>  * Add custom intervals here if you want to refer to them by key rather 
<span class='line'>2618</span>  * than as a function name.
<span class='line'>2619</span>  * @example
<span class='line'>2620</span>     TimeMap.init({
<span class='line'>2621</span>         bandIntervals: "hr",
<span class='line'>2622</span>         // etc...
<span class='line'>2623</span>     });
<span class='line'>2624</span>  *
<span class='line'>2625</span>  */</span><span class="WHIT">
<span class='line'>2626</span> </span><span class="NAME">TimeMap.intervals</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2627</span> </span><span class="WHIT">    </span><span class="COMM">/** second / minute */</span><span class="WHIT">
<span class='line'>2628</span> </span><span class="WHIT">    </span><span class="NAME">sec</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">DateTime.SECOND</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">DateTime.MINUTE</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2629</span> </span><span class="WHIT">    </span><span class="COMM">/** minute / hour */</span><span class="WHIT">
<span class='line'>2630</span> </span><span class="WHIT">    </span><span class="NAME">min</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">DateTime.MINUTE</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">DateTime.HOUR</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2631</span> </span><span class="WHIT">    </span><span class="COMM">/** hour / day */</span><span class="WHIT">
<span class='line'>2632</span> </span><span class="WHIT">    </span><span class="NAME">hr</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">DateTime.HOUR</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">DateTime.DAY</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2633</span> </span><span class="WHIT">    </span><span class="COMM">/** day / week */</span><span class="WHIT">
<span class='line'>2634</span> </span><span class="WHIT">    </span><span class="NAME">day</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">DateTime.DAY</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">DateTime.WEEK</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2635</span> </span><span class="WHIT">    </span><span class="COMM">/** week / month */</span><span class="WHIT">
<span class='line'>2636</span> </span><span class="WHIT">    </span><span class="NAME">wk</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">DateTime.WEEK</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">DateTime.MONTH</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2637</span> </span><span class="WHIT">    </span><span class="COMM">/** month / year */</span><span class="WHIT">
<span class='line'>2638</span> </span><span class="WHIT">    </span><span class="NAME">mon</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">DateTime.MONTH</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">DateTime.YEAR</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2639</span> </span><span class="WHIT">    </span><span class="COMM">/** year / decade */</span><span class="WHIT">
<span class='line'>2640</span> </span><span class="WHIT">    </span><span class="NAME">yr</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">DateTime.YEAR</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">DateTime.DECADE</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2641</span> </span><span class="WHIT">    </span><span class="COMM">/** decade / century */</span><span class="WHIT">
<span class='line'>2642</span> </span><span class="WHIT">    </span><span class="NAME">dec</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">DateTime.DECADE</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">DateTime.CENTURY</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>2643</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2644</span> 
<span class='line'>2645</span> </span><span class="COMM">/**
<span class='line'>2646</span>  * @namespace
<span class='line'>2647</span>  * Lookup map of Google map types. You could add 
<span class='line'>2648</span>  * G_MOON_VISIBLE_MAP, G_SKY_VISIBLE_MAP, or G_MARS_VISIBLE_MAP 
<span class='line'>2649</span>  * if you really needed them.
<span class='line'>2650</span>  * @example
<span class='line'>2651</span>     TimeMap.init({
<span class='line'>2652</span>         options: {
<span class='line'>2653</span>             mapType: "satellite"
<span class='line'>2654</span>         },
<span class='line'>2655</span>         // etc...
<span class='line'>2656</span>     });
<span class='line'>2657</span>  */</span><span class="WHIT">
<span class='line'>2658</span> </span><span class="NAME">TimeMap.mapTypes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2659</span> </span><span class="WHIT">    </span><span class="COMM">/** Normal map */</span><span class="WHIT">
<span class='line'>2660</span> </span><span class="WHIT">    </span><span class="NAME">normal</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">G_NORMAL_MAP</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>2661</span>     </span><span class="COMM">/** Satellite map */</span><span class="WHIT">
<span class='line'>2662</span> </span><span class="WHIT">    </span><span class="NAME">satellite</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">G_SATELLITE_MAP</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>2663</span>     </span><span class="COMM">/** Hybrid map */</span><span class="WHIT">
<span class='line'>2664</span> </span><span class="WHIT">    </span><span class="NAME">hybrid</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">G_HYBRID_MAP</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2665</span> </span><span class="WHIT">    </span><span class="COMM">/** Physical (terrain) map */</span><span class="WHIT">
<span class='line'>2666</span> </span><span class="WHIT">    </span><span class="NAME">physical</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">G_PHYSICAL_MAP</span><span class="WHIT">
<span class='line'>2667</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2668</span> 
<span class='line'>2669</span> </span><span class="COMM">/**
<span class='line'>2670</span>  * @namespace
<span class='line'>2671</span>  * Lookup map of supported date parser functions. 
<span class='line'>2672</span>  * Add custom date parsers here if you want to refer to them by key rather 
<span class='line'>2673</span>  * than as a function name.
<span class='line'>2674</span>  * @example
<span class='line'>2675</span>     TimeMap.init({
<span class='line'>2676</span>         datasets: [
<span class='line'>2677</span>             {
<span class='line'>2678</span>                 options: {
<span class='line'>2679</span>                     dateParser: "gregorian"
<span class='line'>2680</span>                 },
<span class='line'>2681</span>                 // etc...
<span class='line'>2682</span>             }
<span class='line'>2683</span>         ],
<span class='line'>2684</span>         // etc...
<span class='line'>2685</span>     });
<span class='line'>2686</span>  */</span><span class="WHIT">
<span class='line'>2687</span> </span><span class="NAME">TimeMap.dateParsers</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2688</span> </span><span class="WHIT">    </span><span class="COMM">/** Hybrid parser: see {@link TimeMapDataset.hybridParser} */</span><span class="WHIT">
<span class='line'>2689</span> </span><span class="WHIT">    </span><span class="NAME">hybrid</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">TimeMapDataset.hybridParser</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2690</span> </span><span class="WHIT">    </span><span class="COMM">/** ISO8601 parser: parse ISO8601 datetime strings */</span><span class="WHIT">
<span class='line'>2691</span> </span><span class="WHIT">    </span><span class="NAME">iso8601</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">DateTime.parseIso8601DateTime</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2692</span> </span><span class="WHIT">    </span><span class="COMM">/** Gregorian parser: see {@link TimeMapDataset.gregorianParser} */</span><span class="WHIT">
<span class='line'>2693</span> </span><span class="WHIT">    </span><span class="NAME">gregorian</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">TimeMapDataset.gregorianParser</span><span class="WHIT">
<span class='line'>2694</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2695</span> </span><span class="WHIT"> 
<span class='line'>2696</span> </span><span class="COMM">/**
<span class='line'>2697</span>  * @namespace
<span class='line'>2698</span>  * Pre-set event/placemark themes in a variety of colors. 
<span class='line'>2699</span>  * Add custom themes here if you want to refer to them by key rather 
<span class='line'>2700</span>  * than as a function name.
<span class='line'>2701</span>  * @example
<span class='line'>2702</span>     TimeMap.init({
<span class='line'>2703</span>         options: {
<span class='line'>2704</span>             theme: "orange"
<span class='line'>2705</span>         },
<span class='line'>2706</span>         datasets: [
<span class='line'>2707</span>             {
<span class='line'>2708</span>                 options: {
<span class='line'>2709</span>                     theme: "yellow"
<span class='line'>2710</span>                 },
<span class='line'>2711</span>                 // etc...
<span class='line'>2712</span>             }
<span class='line'>2713</span>         ],
<span class='line'>2714</span>         // etc...
<span class='line'>2715</span>     });
<span class='line'>2716</span>  */</span><span class="WHIT">
<span class='line'>2717</span> </span><span class="NAME">TimeMap.themes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2718</span> 
<span class='line'>2719</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>2720</span>      * Red theme: &lt;span style="background:#FE766A">#FE766A&lt;/span>
<span class='line'>2721</span>      * This is the default.
<span class='line'>2722</span>      *
<span class='line'>2723</span>      * @type TimeMapTheme
<span class='line'>2724</span>      */</span><span class="WHIT">
<span class='line'>2725</span> </span><span class="WHIT">    </span><span class="NAME">red</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2726</span> </span><span class="WHIT">    
<span class='line'>2727</span>     </span><span class="COMM">/** 
<span class='line'>2728</span>      * Blue theme: &lt;span style="background:#5A7ACF">#5A7ACF&lt;/span>
<span class='line'>2729</span>      *
<span class='line'>2730</span>      * @type TimeMapTheme
<span class='line'>2731</span>      */</span><span class="WHIT">
<span class='line'>2732</span> </span><span class="WHIT">    </span><span class="NAME">blue</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2733</span> </span><span class="WHIT">        </span><span class="NAME">iconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">GIP</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"blue-dot.png"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2734</span> </span><span class="WHIT">        </span><span class="NAME">color</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"#5A7ACF"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2735</span> </span><span class="WHIT">        </span><span class="NAME">eventIconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"blue-circle.png"</span><span class="WHIT">
<span class='line'>2736</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2737</span> 
<span class='line'>2738</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>2739</span>      * Green theme: &lt;span style="background:#19CF54">#19CF54&lt;/span>
<span class='line'>2740</span>      *
<span class='line'>2741</span>      * @type TimeMapTheme
<span class='line'>2742</span>      */</span><span class="WHIT">
<span class='line'>2743</span> </span><span class="WHIT">    </span><span class="NAME">green</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2744</span> </span><span class="WHIT">        </span><span class="NAME">iconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">GIP</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"green-dot.png"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2745</span> </span><span class="WHIT">        </span><span class="NAME">color</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"#19CF54"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2746</span> </span><span class="WHIT">        </span><span class="NAME">eventIconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"green-circle.png"</span><span class="WHIT">
<span class='line'>2747</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2748</span> 
<span class='line'>2749</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>2750</span>      * Light blue theme: &lt;span style="background:#5ACFCF">#5ACFCF&lt;/span>
<span class='line'>2751</span>      *
<span class='line'>2752</span>      * @type TimeMapTheme
<span class='line'>2753</span>      */</span><span class="WHIT">
<span class='line'>2754</span> </span><span class="WHIT">    </span><span class="NAME">ltblue</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2755</span> </span><span class="WHIT">        </span><span class="NAME">iconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">GIP</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"ltblue-dot.png"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2756</span> </span><span class="WHIT">        </span><span class="NAME">color</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"#5ACFCF"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2757</span> </span><span class="WHIT">        </span><span class="NAME">eventIconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"ltblue-circle.png"</span><span class="WHIT">
<span class='line'>2758</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2759</span> 
<span class='line'>2760</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>2761</span>      * Purple theme: &lt;span style="background:#8E67FD">#8E67FD&lt;/span>
<span class='line'>2762</span>      *
<span class='line'>2763</span>      * @type TimeMapTheme
<span class='line'>2764</span>      */</span><span class="WHIT">
<span class='line'>2765</span> </span><span class="WHIT">    </span><span class="NAME">purple</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2766</span> </span><span class="WHIT">        </span><span class="NAME">iconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">GIP</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"purple-dot.png"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2767</span> </span><span class="WHIT">        </span><span class="NAME">color</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"#8E67FD"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2768</span> </span><span class="WHIT">        </span><span class="NAME">eventIconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"purple-circle.png"</span><span class="WHIT">
<span class='line'>2769</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2770</span> 
<span class='line'>2771</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>2772</span>      * Orange theme: &lt;span style="background:#FF9900">#FF9900&lt;/span>
<span class='line'>2773</span>      *
<span class='line'>2774</span>      * @type TimeMapTheme
<span class='line'>2775</span>      */</span><span class="WHIT">
<span class='line'>2776</span> </span><span class="WHIT">    </span><span class="NAME">orange</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2777</span> </span><span class="WHIT">        </span><span class="NAME">iconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">GIP</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"orange-dot.png"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2778</span> </span><span class="WHIT">        </span><span class="NAME">color</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"#FF9900"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2779</span> </span><span class="WHIT">        </span><span class="NAME">eventIconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"orange-circle.png"</span><span class="WHIT">
<span class='line'>2780</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2781</span> 
<span class='line'>2782</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>2783</span>      * Yellow theme: &lt;span style="background:#FF9900">#ECE64A&lt;/span>
<span class='line'>2784</span>      *
<span class='line'>2785</span>      * @type TimeMapTheme
<span class='line'>2786</span>      */</span><span class="WHIT">
<span class='line'>2787</span> </span><span class="WHIT">    </span><span class="NAME">yellow</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2788</span> </span><span class="WHIT">        </span><span class="NAME">iconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">GIP</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"yellow-dot.png"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2789</span> </span><span class="WHIT">        </span><span class="NAME">color</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"#ECE64A"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2790</span> </span><span class="WHIT">        </span><span class="NAME">eventIconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"yellow-circle.png"</span><span class="WHIT">
<span class='line'>2791</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2792</span> 
<span class='line'>2793</span> </span><span class="WHIT">    </span><span class="COMM">/** 
<span class='line'>2794</span>      * Pink theme: &lt;span style="background:#E14E9D">#E14E9D&lt;/span>
<span class='line'>2795</span>      *
<span class='line'>2796</span>      * @type TimeMapTheme
<span class='line'>2797</span>      */</span><span class="WHIT">
<span class='line'>2798</span> </span><span class="WHIT">    </span><span class="NAME">pink</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>2799</span> </span><span class="WHIT">        </span><span class="NAME">iconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">GIP</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"pink-dot.png"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2800</span> </span><span class="WHIT">        </span><span class="NAME">color</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"#E14E9D"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>2801</span> </span><span class="WHIT">        </span><span class="NAME">eventIconImage</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"pink-circle.png"</span><span class="WHIT">
<span class='line'>2802</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>2803</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2804</span> 
<span class='line'>2805</span> </span><span class="COMM">// save to window</span><span class="WHIT">
<span class='line'>2806</span> </span><span class="NAME">window.TimeMap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2807</span> </span><span class="NAME">window.TimeMapFilterChain</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMapFilterChain</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2808</span> </span><span class="NAME">window.TimeMapDataset</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMapDataset</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2809</span> </span><span class="NAME">window.TimeMapTheme</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMapTheme</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2810</span> </span><span class="NAME">window.TimeMapItem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMapItem</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2811</span> 
<span class='line'>2812</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>2813</span> </span></pre></body></html>